1/*
2 * Board-specific sbf ddr/sdram init.
3 *
4 * (C) Copyright 2017 Angelo Dureghello <angelo@sysam.it>
5 *
6 * SPDX-License-Identifier:	GPL-2.0+
7 */
8
9.global sbf_dram_init
10.text
11
12sbf_dram_init:
13	move.l	#0xFC04002D, %a1
14	move.b	#46, (%a1)		/* DDR */
15
16	/* slew settings */
17	move.l	#0xEC094060, %a1
18	move.b	#0, (%a1)
19
20	/* use vco instead of cpu*2 clock for ddr clock */
21	move.l	#0xEC09001A, %a1
22	move.w	#0xE01D, (%a1)
23
24	/* DDR settings */
25	move.l	#0xFC0B8180, %a1
26	move.l	#0x00000000, (%a1)
27	move.l	#0x40000000, (%a1)
28
29	move.l	#0xFC0B81AC, %a1
30	move.l	#0x01030203, (%a1)
31
32	move.l	#0xFC0B8000, %a1
33	move.l	#0x01010101, (%a1)+	/* 0x00 */
34	move.l	#0x00000101, (%a1)+	/* 0x04 */
35	move.l	#0x01010100, (%a1)+	/* 0x08 */
36	move.l	#0x01010000, (%a1)+	/* 0x0C */
37	move.l	#0x00010101, (%a1)+	/* 0x10 */
38	move.l	#0xFC0B8018, %a1
39	move.l	#0x00010100, (%a1)+	/* 0x18 */
40	move.l	#0x00000001, (%a1)+	/* 0x1C */
41	move.l	#0x01000001, (%a1)+	/* 0x20 */
42	move.l	#0x00000100, (%a1)+	/* 0x24 */
43	move.l	#0x00010001, (%a1)+	/* 0x28 */
44	move.l	#0x00000200, (%a1)+	/* 0x2C */
45	move.l	#0x01000002, (%a1)+	/* 0x30 */
46	move.l	#0x00000000, (%a1)+	/* 0x34 */
47	move.l	#0x00000100, (%a1)+	/* 0x38 */
48	move.l	#0x02000100, (%a1)+	/* 0x3C */
49	move.l	#0x02000407, (%a1)+	/* 0x40 */
50	move.l	#0x02030007, (%a1)+	/* 0x44 */
51	move.l	#0x02000100, (%a1)+	/* 0x48 */
52	move.l	#0x0A030203, (%a1)+	/* 0x4C */
53	move.l	#0x00020708, (%a1)+	/* 0x50 */
54	move.l	#0x00050008, (%a1)+	/* 0x54 */
55	move.l	#0x04030002, (%a1)+	/* 0x58 */
56	move.l	#0x00000004, (%a1)+	/* 0x5C */
57	move.l	#0x020A0000, (%a1)+	/* 0x60 */
58	move.l	#0x0C00000E, (%a1)+	/* 0x64 */
59	move.l	#0x00002004, (%a1)+	/* 0x68 */
60	move.l	#0x00000000, (%a1)+	/* 0x6C */
61	move.l	#0x00100010, (%a1)+	/* 0x70 */
62	move.l	#0x00100010, (%a1)+	/* 0x74 */
63	move.l	#0x00000000, (%a1)+	/* 0x78 */
64	move.l	#0x07990000, (%a1)+	/* 0x7C */
65	move.l	#0xFC0B80A0, %a1
66	move.l	#0x00000000, (%a1)+	/* 0xA0 */
67	move.l	#0x00C80064, (%a1)+	/* 0xA4 */
68	move.l	#0x44520002, (%a1)+	/* 0xA8 */
69	move.l	#0x00C80023, (%a1)+	/* 0xAC */
70	move.l	#0xFC0B80B4, %a1
71	move.l	#0x0000C350, (%a1)	/* 0xB4 */
72	move.l	#0xFC0B80E0, %a1
73	move.l	#0x04000000, (%a1)+	/* 0xE0 */
74	move.l	#0x03000304, (%a1)+	/* 0xE4 */
75	move.l	#0x40040000, (%a1)+	/* 0xE8 */
76	move.l	#0xC0004004, (%a1)+	/* 0xEC */
77	move.l	#0x0642C000, (%a1)+	/* 0xF0 */
78	move.l	#0x00000642, (%a1)+	/* 0xF4 */
79	move.l	#0xFC0B8024, %a1
80	tpf
81	move.l	#0x01000100, (%a1)	/* 0x24 */
82
83	move.l	#0x2000, %d1
84	bsr	asm_delay
85
86	rts
87