xref: /openbmc/u-boot/board/renesas/gose/gose_spl.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0
249aefe30SMarek Vasut /*
349aefe30SMarek Vasut  * board/renesas/gose/gose_spl.c
449aefe30SMarek Vasut  *
549aefe30SMarek Vasut  * Copyright (C) 2018 Marek Vasut <marek.vasut@gmail.com>
649aefe30SMarek Vasut  */
749aefe30SMarek Vasut 
849aefe30SMarek Vasut #include <common.h>
949aefe30SMarek Vasut #include <malloc.h>
1049aefe30SMarek Vasut #include <dm/platform_data/serial_sh.h>
1149aefe30SMarek Vasut #include <asm/processor.h>
1249aefe30SMarek Vasut #include <asm/mach-types.h>
1349aefe30SMarek Vasut #include <asm/io.h>
1449aefe30SMarek Vasut #include <linux/errno.h>
1549aefe30SMarek Vasut #include <asm/arch/sys_proto.h>
1649aefe30SMarek Vasut #include <asm/gpio.h>
1749aefe30SMarek Vasut #include <asm/arch/rmobile.h>
1849aefe30SMarek Vasut #include <asm/arch/rcar-mstp.h>
1949aefe30SMarek Vasut 
2049aefe30SMarek Vasut #include <spl.h>
2149aefe30SMarek Vasut 
2249aefe30SMarek Vasut #define TMU0_MSTP125	BIT(25)
2349aefe30SMarek Vasut #define SCIF0_MSTP721	BIT(21)
2449aefe30SMarek Vasut #define QSPI_MSTP917	BIT(17)
2549aefe30SMarek Vasut 
2649aefe30SMarek Vasut #define SD2CKCR		0xE615026C
2749aefe30SMarek Vasut #define SD_97500KHZ	0x7
2849aefe30SMarek Vasut 
2949aefe30SMarek Vasut struct reg_config {
3049aefe30SMarek Vasut 	u16	off;
3149aefe30SMarek Vasut 	u32	val;
3249aefe30SMarek Vasut };
3349aefe30SMarek Vasut 
dbsc_wait(u16 reg)3449aefe30SMarek Vasut static void dbsc_wait(u16 reg)
3549aefe30SMarek Vasut {
3649aefe30SMarek Vasut 	static const u32 dbsc3_0_base = DBSC3_0_BASE;
3749aefe30SMarek Vasut 
3849aefe30SMarek Vasut 	while (!(readl(dbsc3_0_base + reg) & BIT(0)))
3949aefe30SMarek Vasut 		;
4049aefe30SMarek Vasut }
4149aefe30SMarek Vasut 
spl_init_sys(void)4249aefe30SMarek Vasut static void spl_init_sys(void)
4349aefe30SMarek Vasut {
4449aefe30SMarek Vasut 	u32 r0 = 0;
4549aefe30SMarek Vasut 
4649aefe30SMarek Vasut 	writel(0xa5a5a500, 0xe6020004);
4749aefe30SMarek Vasut 	writel(0xa5a5a500, 0xe6030004);
4849aefe30SMarek Vasut 
4949aefe30SMarek Vasut 	asm volatile(
5049aefe30SMarek Vasut 		/* ICIALLU - Invalidate I$ to PoU */
5149aefe30SMarek Vasut 		"mcr	15, 0, %0, cr7, cr5, 0	\n"
5249aefe30SMarek Vasut 		/* BPIALL - Invalidate branch predictors */
5349aefe30SMarek Vasut 		"mcr	15, 0, %0, cr7, cr5, 6	\n"
5449aefe30SMarek Vasut 		/* Set SCTLR[IZ] */
5549aefe30SMarek Vasut 		"mrc	15, 0, %0, cr1, cr0, 0	\n"
5649aefe30SMarek Vasut 		"orr	%0, #0x1800		\n"
5749aefe30SMarek Vasut 		"mcr	15, 0, %0, cr1, cr0, 0	\n"
5849aefe30SMarek Vasut 		"isb	sy			\n"
5949aefe30SMarek Vasut 		:"=r"(r0));
6049aefe30SMarek Vasut }
6149aefe30SMarek Vasut 
spl_init_pfc(void)6249aefe30SMarek Vasut static void spl_init_pfc(void)
6349aefe30SMarek Vasut {
6449aefe30SMarek Vasut 	static const struct reg_config pfc_with_unlock[] = {
6549aefe30SMarek Vasut 		{ 0x0090, 0x60000000 },
6649aefe30SMarek Vasut 		{ 0x0094, 0x60000000 },
6749aefe30SMarek Vasut 		{ 0x0098, 0x00800200 },
6849aefe30SMarek Vasut 		{ 0x009c, 0x00000000 },
6949aefe30SMarek Vasut 		{ 0x0020, 0x00000000 },
7049aefe30SMarek Vasut 		{ 0x0024, 0x00000000 },
7149aefe30SMarek Vasut 		{ 0x0028, 0x000244c8 },
7249aefe30SMarek Vasut 		{ 0x002c, 0x00000000 },
7349aefe30SMarek Vasut 		{ 0x0030, 0x00002400 },
7449aefe30SMarek Vasut 		{ 0x0034, 0x01520000 },
7549aefe30SMarek Vasut 		{ 0x0038, 0x00724003 },
7649aefe30SMarek Vasut 		{ 0x003c, 0x00000000 },
7749aefe30SMarek Vasut 		{ 0x0040, 0x00000000 },
7849aefe30SMarek Vasut 		{ 0x0044, 0x00000000 },
7949aefe30SMarek Vasut 		{ 0x0048, 0x00000000 },
8049aefe30SMarek Vasut 		{ 0x004c, 0x00000000 },
8149aefe30SMarek Vasut 		{ 0x0050, 0x00000000 },
8249aefe30SMarek Vasut 		{ 0x0054, 0x00000000 },
8349aefe30SMarek Vasut 		{ 0x0058, 0x00000000 },
8449aefe30SMarek Vasut 		{ 0x005c, 0x00000000 },
8549aefe30SMarek Vasut 		{ 0x0160, 0x00000000 },
8649aefe30SMarek Vasut 		{ 0x0004, 0xffffffff },
8749aefe30SMarek Vasut 		{ 0x0008, 0x00ec3fff },
8849aefe30SMarek Vasut 		{ 0x000c, 0x3bc001e7 },
8949aefe30SMarek Vasut 		{ 0x0010, 0x5bffffff },
9049aefe30SMarek Vasut 		{ 0x0014, 0x1ffffffb },
9149aefe30SMarek Vasut 		{ 0x0018, 0x01bffff0 },
9249aefe30SMarek Vasut 		{ 0x001c, 0xcf7fffff },
9349aefe30SMarek Vasut 		{ 0x0074, 0x0381fc00 },
9449aefe30SMarek Vasut 	};
9549aefe30SMarek Vasut 
9649aefe30SMarek Vasut 	static const struct reg_config pfc_without_unlock[] = {
9749aefe30SMarek Vasut 		{ 0x0100, 0xffffffdf },
9849aefe30SMarek Vasut 		{ 0x0104, 0xc883c3ff },
9949aefe30SMarek Vasut 		{ 0x0108, 0x1201f3c9 },
10049aefe30SMarek Vasut 		{ 0x010c, 0x00000000 },
10149aefe30SMarek Vasut 		{ 0x0110, 0xffffeb04 },
10249aefe30SMarek Vasut 		{ 0x0114, 0xc003ffff },
10349aefe30SMarek Vasut 		{ 0x0118, 0x0800000f },
10449aefe30SMarek Vasut 		{ 0x011c, 0x001800f0 },
10549aefe30SMarek Vasut 	};
10649aefe30SMarek Vasut 
10749aefe30SMarek Vasut 	static const u32 pfc_base = 0xe6060000;
10849aefe30SMarek Vasut 
10949aefe30SMarek Vasut 	unsigned int i;
11049aefe30SMarek Vasut 
11149aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(pfc_with_unlock); i++) {
11249aefe30SMarek Vasut 		writel(~pfc_with_unlock[i].val, pfc_base);
11349aefe30SMarek Vasut 		writel(pfc_with_unlock[i].val,
11449aefe30SMarek Vasut 		       pfc_base | pfc_with_unlock[i].off);
11549aefe30SMarek Vasut 	}
11649aefe30SMarek Vasut 
11749aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(pfc_without_unlock); i++)
11849aefe30SMarek Vasut 		writel(pfc_without_unlock[i].val,
11949aefe30SMarek Vasut 		       pfc_base | pfc_without_unlock[i].off);
12049aefe30SMarek Vasut }
12149aefe30SMarek Vasut 
spl_init_gpio(void)12249aefe30SMarek Vasut static void spl_init_gpio(void)
12349aefe30SMarek Vasut {
12449aefe30SMarek Vasut 	static const u16 gpio_offs[] = {
12549aefe30SMarek Vasut 		0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x5400, 0x5800
12649aefe30SMarek Vasut 	};
12749aefe30SMarek Vasut 
12849aefe30SMarek Vasut 	static const struct reg_config gpio_set[] = {
12949aefe30SMarek Vasut 		{ 0x2000, 0x04381000 },
13049aefe30SMarek Vasut 		{ 0x5000, 0x00000000 },
13149aefe30SMarek Vasut 		{ 0x5800, 0x000e0000 },
13249aefe30SMarek Vasut 	};
13349aefe30SMarek Vasut 
13449aefe30SMarek Vasut 	static const struct reg_config gpio_clr[] = {
13549aefe30SMarek Vasut 		{ 0x1000, 0x00000000 },
13649aefe30SMarek Vasut 		{ 0x2000, 0x04381010 },
13749aefe30SMarek Vasut 		{ 0x3000, 0x00000000 },
13849aefe30SMarek Vasut 		{ 0x4000, 0x00000000 },
13949aefe30SMarek Vasut 		{ 0x5000, 0x00400000 },
14049aefe30SMarek Vasut 		{ 0x5400, 0x00000000 },
14149aefe30SMarek Vasut 		{ 0x5800, 0x000e0380 },
14249aefe30SMarek Vasut 	};
14349aefe30SMarek Vasut 
14449aefe30SMarek Vasut 	static const u32 gpio_base = 0xe6050000;
14549aefe30SMarek Vasut 
14649aefe30SMarek Vasut 	unsigned int i;
14749aefe30SMarek Vasut 
14849aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(gpio_offs); i++)
14949aefe30SMarek Vasut 		writel(0, gpio_base | 0x20 | gpio_offs[i]);
15049aefe30SMarek Vasut 
15149aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(gpio_offs); i++)
15249aefe30SMarek Vasut 		writel(0, gpio_base | 0x00 | gpio_offs[i]);
15349aefe30SMarek Vasut 
15449aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(gpio_set); i++)
15549aefe30SMarek Vasut 		writel(gpio_set[i].val, gpio_base | 0x08 | gpio_set[i].off);
15649aefe30SMarek Vasut 
15749aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(gpio_clr); i++)
15849aefe30SMarek Vasut 		writel(gpio_clr[i].val, gpio_base | 0x04 | gpio_clr[i].off);
15949aefe30SMarek Vasut }
16049aefe30SMarek Vasut 
spl_init_lbsc(void)16149aefe30SMarek Vasut static void spl_init_lbsc(void)
16249aefe30SMarek Vasut {
16349aefe30SMarek Vasut 	static const struct reg_config lbsc_config[] = {
16449aefe30SMarek Vasut 		{ 0x00, 0x00000020 },
16549aefe30SMarek Vasut 		{ 0x08, 0x00002020 },
16649aefe30SMarek Vasut 		{ 0x30, 0x2a103320 },
16749aefe30SMarek Vasut 		{ 0x38, 0xff70ff70 },
16849aefe30SMarek Vasut 	};
16949aefe30SMarek Vasut 
17049aefe30SMarek Vasut 	static const u16 lbsc_offs[] = {
17149aefe30SMarek Vasut 		0x80, 0x84, 0x88, 0x8c, 0xa0, 0xc0, 0xc4, 0xc8, 0x180
17249aefe30SMarek Vasut 	};
17349aefe30SMarek Vasut 
17449aefe30SMarek Vasut 	static const u32 lbsc_base = 0xfec00200;
17549aefe30SMarek Vasut 
17649aefe30SMarek Vasut 	unsigned int i;
17749aefe30SMarek Vasut 
17849aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(lbsc_config); i++) {
17949aefe30SMarek Vasut 		writel(lbsc_config[i].val,
18049aefe30SMarek Vasut 		       lbsc_base | lbsc_config[i].off);
18149aefe30SMarek Vasut 		writel(lbsc_config[i].val,
18249aefe30SMarek Vasut 		       lbsc_base | (lbsc_config[i].off + 4));
18349aefe30SMarek Vasut 	}
18449aefe30SMarek Vasut 
18549aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(lbsc_offs); i++)
18649aefe30SMarek Vasut 		writel(0, lbsc_base | lbsc_offs[i]);
18749aefe30SMarek Vasut }
18849aefe30SMarek Vasut 
spl_init_dbsc(void)18949aefe30SMarek Vasut static void spl_init_dbsc(void)
19049aefe30SMarek Vasut {
19149aefe30SMarek Vasut 	static const struct reg_config dbsc_config1[] = {
19249aefe30SMarek Vasut 		{ 0x0280, 0x0000a55a },
19349aefe30SMarek Vasut 		{ 0x0018, 0x21000000 },
19449aefe30SMarek Vasut 		{ 0x0018, 0x11000000 },
19549aefe30SMarek Vasut 		{ 0x0018, 0x10000000 },
19649aefe30SMarek Vasut 		{ 0x0290, 0x00000001 },
19749aefe30SMarek Vasut 		{ 0x02a0, 0x80000000 },
19849aefe30SMarek Vasut 		{ 0x0290, 0x00000004 },
19949aefe30SMarek Vasut 	};
20049aefe30SMarek Vasut 
20149aefe30SMarek Vasut 	static const struct reg_config dbsc_config2[] = {
20249aefe30SMarek Vasut 		{ 0x0290, 0x00000006 },
20349aefe30SMarek Vasut 		{ 0x02a0, 0x0001c000 },
20449aefe30SMarek Vasut 	};
20549aefe30SMarek Vasut 
20649aefe30SMarek Vasut 	static const struct reg_config dbsc_config4[] = {
20749aefe30SMarek Vasut 		{ 0x0290, 0x00000010 },
20849aefe30SMarek Vasut 		{ 0x02a0, 0xf00464db },
20949aefe30SMarek Vasut 		{ 0x0290, 0x00000061 },
21049aefe30SMarek Vasut 		{ 0x02a0, 0x0000006d },
21149aefe30SMarek Vasut 		{ 0x0290, 0x00000001 },
21249aefe30SMarek Vasut 		{ 0x02a0, 0x00000073 },
21349aefe30SMarek Vasut 		{ 0x0020, 0x00000007 },
21449aefe30SMarek Vasut 		{ 0x0024, 0x0f030a02 },
21549aefe30SMarek Vasut 		{ 0x0030, 0x00000001 },
21649aefe30SMarek Vasut 		{ 0x00b0, 0x00000000 },
21749aefe30SMarek Vasut 		{ 0x0040, 0x0000000b },
21849aefe30SMarek Vasut 		{ 0x0044, 0x00000008 },
21949aefe30SMarek Vasut 		{ 0x0048, 0x00000000 },
22049aefe30SMarek Vasut 		{ 0x0050, 0x0000000b },
22149aefe30SMarek Vasut 		{ 0x0054, 0x000c000b },
22249aefe30SMarek Vasut 		{ 0x0058, 0x00000027 },
22349aefe30SMarek Vasut 		{ 0x005c, 0x0000001c },
22449aefe30SMarek Vasut 		{ 0x0060, 0x00000006 },
22549aefe30SMarek Vasut 		{ 0x0064, 0x00000020 },
22649aefe30SMarek Vasut 		{ 0x0068, 0x00000008 },
22749aefe30SMarek Vasut 		{ 0x006c, 0x0000000c },
22849aefe30SMarek Vasut 		{ 0x0070, 0x00000009 },
22949aefe30SMarek Vasut 		{ 0x0074, 0x00000012 },
23049aefe30SMarek Vasut 		{ 0x0078, 0x000000d0 },
23149aefe30SMarek Vasut 		{ 0x007c, 0x00140005 },
23249aefe30SMarek Vasut 		{ 0x0080, 0x00050004 },
23349aefe30SMarek Vasut 		{ 0x0084, 0x70233005 },
23449aefe30SMarek Vasut 		{ 0x0088, 0x000c0000 },
23549aefe30SMarek Vasut 		{ 0x008c, 0x00000200 },
23649aefe30SMarek Vasut 		{ 0x0090, 0x00000040 },
23749aefe30SMarek Vasut 		{ 0x0100, 0x00000001 },
23849aefe30SMarek Vasut 		{ 0x00c0, 0x00020001 },
23949aefe30SMarek Vasut 		{ 0x00c8, 0x20042004 },
24049aefe30SMarek Vasut 		{ 0x0380, 0x00020002 },
24149aefe30SMarek Vasut 		{ 0x0390, 0x0000001f },
24249aefe30SMarek Vasut 	};
24349aefe30SMarek Vasut 
24449aefe30SMarek Vasut 	static const struct reg_config dbsc_config5[] = {
24549aefe30SMarek Vasut 		{ 0x0244, 0x00000011 },
24649aefe30SMarek Vasut 		{ 0x0290, 0x00000003 },
24749aefe30SMarek Vasut 		{ 0x02a0, 0x0300c561 },
24849aefe30SMarek Vasut 		{ 0x0290, 0x00000023 },
24949aefe30SMarek Vasut 		{ 0x02a0, 0x00fcdb60 },
25049aefe30SMarek Vasut 		{ 0x0290, 0x00000011 },
25149aefe30SMarek Vasut 		{ 0x02a0, 0x1000040b },
25249aefe30SMarek Vasut 		{ 0x0290, 0x00000012 },
25349aefe30SMarek Vasut 		{ 0x02a0, 0x9d9cbb66 },
25449aefe30SMarek Vasut 		{ 0x0290, 0x00000013 },
25549aefe30SMarek Vasut 		{ 0x02a0, 0x1a868400 },
25649aefe30SMarek Vasut 		{ 0x0290, 0x00000014 },
25749aefe30SMarek Vasut 		{ 0x02a0, 0x300214d8 },
25849aefe30SMarek Vasut 		{ 0x0290, 0x00000015 },
25949aefe30SMarek Vasut 		{ 0x02a0, 0x00000d70 },
26049aefe30SMarek Vasut 		{ 0x0290, 0x00000016 },
26149aefe30SMarek Vasut 		{ 0x02a0, 0x00000006 },
26249aefe30SMarek Vasut 		{ 0x0290, 0x00000017 },
26349aefe30SMarek Vasut 		{ 0x02a0, 0x00000018 },
26449aefe30SMarek Vasut 		{ 0x0290, 0x0000001a },
26549aefe30SMarek Vasut 		{ 0x02a0, 0x910035c7 },
26649aefe30SMarek Vasut 		{ 0x0290, 0x00000004 },
26749aefe30SMarek Vasut 	};
26849aefe30SMarek Vasut 
26949aefe30SMarek Vasut 	static const struct reg_config dbsc_config6[] = {
27049aefe30SMarek Vasut 		{ 0x0290, 0x00000001 },
27149aefe30SMarek Vasut 		{ 0x02a0, 0x00000181 },
27249aefe30SMarek Vasut 		{ 0x0018, 0x11000000 },
27349aefe30SMarek Vasut 		{ 0x0290, 0x00000004 },
27449aefe30SMarek Vasut 	};
27549aefe30SMarek Vasut 
27649aefe30SMarek Vasut 	static const struct reg_config dbsc_config7[] = {
27749aefe30SMarek Vasut 		{ 0x0290, 0x00000001 },
27849aefe30SMarek Vasut 		{ 0x02a0, 0x0000fe01 },
27949aefe30SMarek Vasut 		{ 0x0304, 0x00000000 },
28049aefe30SMarek Vasut 		{ 0x00f4, 0x01004c20 },
28149aefe30SMarek Vasut 		{ 0x00f8, 0x014000aa },
28249aefe30SMarek Vasut 		{ 0x00e0, 0x00000140 },
28349aefe30SMarek Vasut 		{ 0x00e4, 0x00081860 },
28449aefe30SMarek Vasut 		{ 0x00e8, 0x00010000 },
28549aefe30SMarek Vasut 		{ 0x0290, 0x00000004 },
28649aefe30SMarek Vasut 	};
28749aefe30SMarek Vasut 
28849aefe30SMarek Vasut 	static const struct reg_config dbsc_config8[] = {
28949aefe30SMarek Vasut 		{ 0x0014, 0x00000001 },
29049aefe30SMarek Vasut 		{ 0x0010, 0x00000001 },
29149aefe30SMarek Vasut 		{ 0x0280, 0x00000000 },
29249aefe30SMarek Vasut 	};
29349aefe30SMarek Vasut 
29449aefe30SMarek Vasut 	static const u32 dbsc3_0_base = DBSC3_0_BASE;
29549aefe30SMarek Vasut 	unsigned int i;
29649aefe30SMarek Vasut 
29749aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config1); i++)
29849aefe30SMarek Vasut 		writel(dbsc_config1[i].val, dbsc3_0_base | dbsc_config1[i].off);
29949aefe30SMarek Vasut 
30049aefe30SMarek Vasut 	dbsc_wait(0x2a0);
30149aefe30SMarek Vasut 
30249aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config2); i++)
30349aefe30SMarek Vasut 		writel(dbsc_config2[i].val, dbsc3_0_base | dbsc_config2[i].off);
30449aefe30SMarek Vasut 
30549aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config4); i++)
30649aefe30SMarek Vasut 		writel(dbsc_config4[i].val, dbsc3_0_base | dbsc_config4[i].off);
30749aefe30SMarek Vasut 
30849aefe30SMarek Vasut 	dbsc_wait(0x240);
30949aefe30SMarek Vasut 
31049aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config5); i++)
31149aefe30SMarek Vasut 		writel(dbsc_config5[i].val, dbsc3_0_base | dbsc_config5[i].off);
31249aefe30SMarek Vasut 
31349aefe30SMarek Vasut 	dbsc_wait(0x2a0);
31449aefe30SMarek Vasut 
31549aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config6); i++)
31649aefe30SMarek Vasut 		writel(dbsc_config6[i].val, dbsc3_0_base | dbsc_config6[i].off);
31749aefe30SMarek Vasut 
31849aefe30SMarek Vasut 	dbsc_wait(0x2a0);
31949aefe30SMarek Vasut 
32049aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config7); i++)
32149aefe30SMarek Vasut 		writel(dbsc_config7[i].val, dbsc3_0_base | dbsc_config7[i].off);
32249aefe30SMarek Vasut 
32349aefe30SMarek Vasut 	dbsc_wait(0x2a0);
32449aefe30SMarek Vasut 
32549aefe30SMarek Vasut 	for (i = 0; i < ARRAY_SIZE(dbsc_config8); i++)
32649aefe30SMarek Vasut 		writel(dbsc_config8[i].val, dbsc3_0_base | dbsc_config8[i].off);
32749aefe30SMarek Vasut 
32849aefe30SMarek Vasut }
32949aefe30SMarek Vasut 
spl_init_qspi(void)33049aefe30SMarek Vasut static void spl_init_qspi(void)
33149aefe30SMarek Vasut {
33249aefe30SMarek Vasut 	mstp_clrbits_le32(MSTPSR9, SMSTPCR9, QSPI_MSTP917);
33349aefe30SMarek Vasut 
33449aefe30SMarek Vasut 	static const u32 qspi_base = 0xe6b10000;
33549aefe30SMarek Vasut 
33649aefe30SMarek Vasut 	writeb(0x08, qspi_base + 0x00);
33749aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x01);
33849aefe30SMarek Vasut 	writeb(0x06, qspi_base + 0x02);
33949aefe30SMarek Vasut 	writeb(0x01, qspi_base + 0x0a);
34049aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x0b);
34149aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x0c);
34249aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x0d);
34349aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x0e);
34449aefe30SMarek Vasut 
34549aefe30SMarek Vasut 	writew(0xe080, qspi_base + 0x10);
34649aefe30SMarek Vasut 
34749aefe30SMarek Vasut 	writeb(0xc0, qspi_base + 0x18);
34849aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x18);
34949aefe30SMarek Vasut 	writeb(0x00, qspi_base + 0x08);
35049aefe30SMarek Vasut 	writeb(0x48, qspi_base + 0x00);
35149aefe30SMarek Vasut }
35249aefe30SMarek Vasut 
board_init_f(ulong dummy)35349aefe30SMarek Vasut void board_init_f(ulong dummy)
35449aefe30SMarek Vasut {
35549aefe30SMarek Vasut 	mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125);
35649aefe30SMarek Vasut 	mstp_clrbits_le32(MSTPSR7, SMSTPCR7, SCIF0_MSTP721);
35749aefe30SMarek Vasut 
35849aefe30SMarek Vasut 	/*
35949aefe30SMarek Vasut 	 * SD0 clock is set to 97.5MHz by default.
36049aefe30SMarek Vasut 	 * Set SD2 to the 97.5MHz as well.
36149aefe30SMarek Vasut 	 */
36249aefe30SMarek Vasut 	writel(SD_97500KHZ, SD2CKCR);
36349aefe30SMarek Vasut 
36449aefe30SMarek Vasut 	spl_init_sys();
36549aefe30SMarek Vasut 	spl_init_pfc();
36649aefe30SMarek Vasut 	spl_init_gpio();
36749aefe30SMarek Vasut 	spl_init_lbsc();
36849aefe30SMarek Vasut 	spl_init_dbsc();
36949aefe30SMarek Vasut 	spl_init_qspi();
37049aefe30SMarek Vasut }
37149aefe30SMarek Vasut 
spl_board_init(void)37249aefe30SMarek Vasut void spl_board_init(void)
37349aefe30SMarek Vasut {
37449aefe30SMarek Vasut 	/* UART clocks enabled and gd valid - init serial console */
37549aefe30SMarek Vasut 	preloader_console_init();
37649aefe30SMarek Vasut }
37749aefe30SMarek Vasut 
board_boot_order(u32 * spl_boot_list)37849aefe30SMarek Vasut void board_boot_order(u32 *spl_boot_list)
37949aefe30SMarek Vasut {
38049aefe30SMarek Vasut 	const u32 jtag_magic = 0x1337c0de;
38149aefe30SMarek Vasut 	const u32 load_magic = 0xb33fc0de;
38249aefe30SMarek Vasut 
38349aefe30SMarek Vasut 	/*
38449aefe30SMarek Vasut 	 * If JTAG probe sets special word at 0xe6300020, then it must
38549aefe30SMarek Vasut 	 * put U-Boot into RAM and SPL will start it from RAM.
38649aefe30SMarek Vasut 	 */
38749aefe30SMarek Vasut 	if (readl(CONFIG_SPL_TEXT_BASE + 0x20) == jtag_magic) {
38849aefe30SMarek Vasut 		printf("JTAG boot detected!\n");
38949aefe30SMarek Vasut 
39049aefe30SMarek Vasut 		while (readl(CONFIG_SPL_TEXT_BASE + 0x24) != load_magic)
39149aefe30SMarek Vasut 			;
39249aefe30SMarek Vasut 
39349aefe30SMarek Vasut 		spl_boot_list[0] = BOOT_DEVICE_RAM;
39449aefe30SMarek Vasut 		spl_boot_list[1] = BOOT_DEVICE_NONE;
39549aefe30SMarek Vasut 
39649aefe30SMarek Vasut 		return;
39749aefe30SMarek Vasut 	}
39849aefe30SMarek Vasut 
39949aefe30SMarek Vasut 	/* Boot from SPI NOR with YMODEM UART fallback. */
40049aefe30SMarek Vasut 	spl_boot_list[0] = BOOT_DEVICE_SPI;
40149aefe30SMarek Vasut 	spl_boot_list[1] = BOOT_DEVICE_UART;
40249aefe30SMarek Vasut 	spl_boot_list[2] = BOOT_DEVICE_NONE;
40349aefe30SMarek Vasut }
40449aefe30SMarek Vasut 
reset_cpu(ulong addr)40549aefe30SMarek Vasut void reset_cpu(ulong addr)
40649aefe30SMarek Vasut {
40749aefe30SMarek Vasut }
408