1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2fd697ecfSMasahiro Yamada /*
3fd697ecfSMasahiro Yamada * Copyright (C) 2010 Albert ARIBAUD <albert.u.boot@aribaud.net>
4fd697ecfSMasahiro Yamada *
5fd697ecfSMasahiro Yamada * Based on original Kirorion5x_ood support which is
6fd697ecfSMasahiro Yamada * (C) Copyright 2009
7fd697ecfSMasahiro Yamada * Marvell Semiconductor <www.marvell.com>
8fd697ecfSMasahiro Yamada * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
9fd697ecfSMasahiro Yamada */
10fd697ecfSMasahiro Yamada
11fd697ecfSMasahiro Yamada #ifndef _ORION5X_CPU_H
12fd697ecfSMasahiro Yamada #define _ORION5X_CPU_H
13fd697ecfSMasahiro Yamada
14fd697ecfSMasahiro Yamada #include <asm/system.h>
15fd697ecfSMasahiro Yamada
16fd697ecfSMasahiro Yamada #ifndef __ASSEMBLY__
17fd697ecfSMasahiro Yamada
18fd697ecfSMasahiro Yamada #define ORION5X_CPU_WIN_CTRL_DATA(size, target, attr, en) (en | (target << 4) \
19fd697ecfSMasahiro Yamada | (attr << 8) | (orion5x_winctrl_calcsize(size) << 16))
20fd697ecfSMasahiro Yamada
21fd697ecfSMasahiro Yamada #define ORION5XGBE_PORT_SERIAL_CONTROL1_REG(_x) \
22fd697ecfSMasahiro Yamada ((_x ? ORION5X_EGIGA0_BASE : ORION5X_EGIGA1_BASE) + 0x44c)
23fd697ecfSMasahiro Yamada
24fd697ecfSMasahiro Yamada enum memory_bank {
25fd697ecfSMasahiro Yamada BANK0,
26fd697ecfSMasahiro Yamada BANK1,
27fd697ecfSMasahiro Yamada BANK2,
28fd697ecfSMasahiro Yamada BANK3
29fd697ecfSMasahiro Yamada };
30fd697ecfSMasahiro Yamada
31fd697ecfSMasahiro Yamada enum orion5x_cpu_winen {
32fd697ecfSMasahiro Yamada ORION5X_WIN_DISABLE,
33fd697ecfSMasahiro Yamada ORION5X_WIN_ENABLE
34fd697ecfSMasahiro Yamada };
35fd697ecfSMasahiro Yamada
36fd697ecfSMasahiro Yamada enum orion5x_cpu_target {
37fd697ecfSMasahiro Yamada ORION5X_TARGET_DRAM = 0,
38fd697ecfSMasahiro Yamada ORION5X_TARGET_DEVICE = 1,
39fd697ecfSMasahiro Yamada ORION5X_TARGET_PCI = 3,
40fd697ecfSMasahiro Yamada ORION5X_TARGET_PCIE = 4,
41fd697ecfSMasahiro Yamada ORION5X_TARGET_SASRAM = 9
42fd697ecfSMasahiro Yamada };
43fd697ecfSMasahiro Yamada
44fd697ecfSMasahiro Yamada enum orion5x_cpu_attrib {
45fd697ecfSMasahiro Yamada ORION5X_ATTR_DRAM_CS0 = 0x0e,
46fd697ecfSMasahiro Yamada ORION5X_ATTR_DRAM_CS1 = 0x0d,
47fd697ecfSMasahiro Yamada ORION5X_ATTR_DRAM_CS2 = 0x0b,
48fd697ecfSMasahiro Yamada ORION5X_ATTR_DRAM_CS3 = 0x07,
49fd697ecfSMasahiro Yamada ORION5X_ATTR_PCI_MEM = 0x59,
50fd697ecfSMasahiro Yamada ORION5X_ATTR_PCI_IO = 0x51,
51fd697ecfSMasahiro Yamada ORION5X_ATTR_PCIE_MEM = 0x59,
52fd697ecfSMasahiro Yamada ORION5X_ATTR_PCIE_IO = 0x51,
53fd697ecfSMasahiro Yamada ORION5X_ATTR_SASRAM = 0x00,
54fd697ecfSMasahiro Yamada ORION5X_ATTR_DEV_CS0 = 0x1e,
55fd697ecfSMasahiro Yamada ORION5X_ATTR_DEV_CS1 = 0x1d,
56fd697ecfSMasahiro Yamada ORION5X_ATTR_DEV_CS2 = 0x1b,
57fd697ecfSMasahiro Yamada ORION5X_ATTR_BOOTROM = 0x0f
58fd697ecfSMasahiro Yamada };
59fd697ecfSMasahiro Yamada
60fd697ecfSMasahiro Yamada /*
61fd697ecfSMasahiro Yamada * Device Address MAP BAR values
62fd697ecfSMasahiro Yamada *
63fd697ecfSMasahiro Yamada * All addresses and sizes not defined by board code
64fd697ecfSMasahiro Yamada * will be given default values here.
65fd697ecfSMasahiro Yamada */
66fd697ecfSMasahiro Yamada
67fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCIE_MEM)
68fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCIE_MEM 0x90000000
69fd697ecfSMasahiro Yamada #endif
70fd697ecfSMasahiro Yamada
71fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCIE_MEM_REMAP_LO)
72fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCIE_MEM_REMAP_LO 0x90000000
73fd697ecfSMasahiro Yamada #endif
74fd697ecfSMasahiro Yamada
75fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCIE_MEM_REMAP_HI)
76fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCIE_MEM_REMAP_HI 0
77fd697ecfSMasahiro Yamada #endif
78fd697ecfSMasahiro Yamada
79fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_PCIE_MEM)
80fd697ecfSMasahiro Yamada #define ORION5X_SZ_PCIE_MEM (128*1024*1024)
81fd697ecfSMasahiro Yamada #endif
82fd697ecfSMasahiro Yamada
83fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCIE_IO)
84fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCIE_IO 0xf0000000
85fd697ecfSMasahiro Yamada #endif
86fd697ecfSMasahiro Yamada
87fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCIE_IO_REMAP_LO)
88c1b0fad9SAlbert ARIBAUD #define ORION5X_ADR_PCIE_IO_REMAP_LO 0xf0000000
89fd697ecfSMasahiro Yamada #endif
90fd697ecfSMasahiro Yamada
91fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCIE_IO_REMAP_HI)
92fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCIE_IO_REMAP_HI 0
93fd697ecfSMasahiro Yamada #endif
94fd697ecfSMasahiro Yamada
95fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_PCIE_IO)
96fd697ecfSMasahiro Yamada #define ORION5X_SZ_PCIE_IO (64*1024)
97fd697ecfSMasahiro Yamada #endif
98fd697ecfSMasahiro Yamada
99fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCI_MEM)
100fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCI_MEM 0x98000000
101fd697ecfSMasahiro Yamada #endif
102fd697ecfSMasahiro Yamada
103fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_PCI_MEM)
104fd697ecfSMasahiro Yamada #define ORION5X_SZ_PCI_MEM (128*1024*1024)
105fd697ecfSMasahiro Yamada #endif
106fd697ecfSMasahiro Yamada
107fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_PCI_IO)
108fd697ecfSMasahiro Yamada #define ORION5X_ADR_PCI_IO 0xf0100000
109fd697ecfSMasahiro Yamada #endif
110fd697ecfSMasahiro Yamada
111fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_PCI_IO)
112fd697ecfSMasahiro Yamada #define ORION5X_SZ_PCI_IO (64*1024)
113fd697ecfSMasahiro Yamada #endif
114fd697ecfSMasahiro Yamada
115fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_DEV_CS0)
116fd697ecfSMasahiro Yamada #define ORION5X_ADR_DEV_CS0 0xfa000000
117fd697ecfSMasahiro Yamada #endif
118fd697ecfSMasahiro Yamada
119fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_DEV_CS0)
120fd697ecfSMasahiro Yamada #define ORION5X_SZ_DEV_CS0 (2*1024*1024)
121fd697ecfSMasahiro Yamada #endif
122fd697ecfSMasahiro Yamada
123fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_DEV_CS1)
124fd697ecfSMasahiro Yamada #define ORION5X_ADR_DEV_CS1 0xf8000000
125fd697ecfSMasahiro Yamada #endif
126fd697ecfSMasahiro Yamada
127fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_DEV_CS1)
128fd697ecfSMasahiro Yamada #define ORION5X_SZ_DEV_CS1 (32*1024*1024)
129fd697ecfSMasahiro Yamada #endif
130fd697ecfSMasahiro Yamada
131fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_DEV_CS2)
132fd697ecfSMasahiro Yamada #define ORION5X_ADR_DEV_CS2 0xfa800000
133fd697ecfSMasahiro Yamada #endif
134fd697ecfSMasahiro Yamada
135fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_DEV_CS2)
136fd697ecfSMasahiro Yamada #define ORION5X_SZ_DEV_CS2 (1*1024*1024)
137fd697ecfSMasahiro Yamada #endif
138fd697ecfSMasahiro Yamada
139fd697ecfSMasahiro Yamada #if !defined (ORION5X_ADR_BOOTROM)
140fd697ecfSMasahiro Yamada #define ORION5X_ADR_BOOTROM 0xFFF80000
141fd697ecfSMasahiro Yamada #endif
142fd697ecfSMasahiro Yamada
143fd697ecfSMasahiro Yamada #if !defined (ORION5X_SZ_BOOTROM)
144fd697ecfSMasahiro Yamada #define ORION5X_SZ_BOOTROM (512*1024)
145fd697ecfSMasahiro Yamada #endif
146fd697ecfSMasahiro Yamada
147fd697ecfSMasahiro Yamada /*
148fd697ecfSMasahiro Yamada * PCIE registers are used for SoC device ID and revision
149fd697ecfSMasahiro Yamada */
150fd697ecfSMasahiro Yamada #define PCIE_DEV_ID_OFF (ORION5X_REG_PCIE_BASE + 0x0000)
151fd697ecfSMasahiro Yamada #define PCIE_DEV_REV_OFF (ORION5X_REG_PCIE_BASE + 0x0008)
152fd697ecfSMasahiro Yamada
153fd697ecfSMasahiro Yamada /*
154fd697ecfSMasahiro Yamada * The following definitions are intended for identifying
155fd697ecfSMasahiro Yamada * the real device and revision on which u-boot is running
156fd697ecfSMasahiro Yamada * even if it was compiled only for a specific one. Thus,
157fd697ecfSMasahiro Yamada * these constants must not be considered chip-specific.
158fd697ecfSMasahiro Yamada */
159fd697ecfSMasahiro Yamada
160fd697ecfSMasahiro Yamada /* Orion-1 (88F5181) and Orion-VoIP (88F5181L) */
161fd697ecfSMasahiro Yamada #define MV88F5181_DEV_ID 0x5181
162fd697ecfSMasahiro Yamada #define MV88F5181_REV_B1 3
163fd697ecfSMasahiro Yamada #define MV88F5181L_REV_A0 8
164fd697ecfSMasahiro Yamada #define MV88F5181L_REV_A1 9
165fd697ecfSMasahiro Yamada /* Orion-NAS (88F5182) */
166fd697ecfSMasahiro Yamada #define MV88F5182_DEV_ID 0x5182
167fd697ecfSMasahiro Yamada #define MV88F5182_REV_A2 2
168fd697ecfSMasahiro Yamada /* Orion-2 (88F5281) */
169fd697ecfSMasahiro Yamada #define MV88F5281_DEV_ID 0x5281
170fd697ecfSMasahiro Yamada #define MV88F5281_REV_D0 4
171fd697ecfSMasahiro Yamada #define MV88F5281_REV_D1 5
172fd697ecfSMasahiro Yamada #define MV88F5281_REV_D2 6
173fd697ecfSMasahiro Yamada /* Orion-1-90 (88F6183) */
174fd697ecfSMasahiro Yamada #define MV88F6183_DEV_ID 0x6183
175fd697ecfSMasahiro Yamada #define MV88F6183_REV_B0 3
176fd697ecfSMasahiro Yamada
177fd697ecfSMasahiro Yamada /*
178fd697ecfSMasahiro Yamada * read feroceon core extra feature register
179fd697ecfSMasahiro Yamada * using co-proc instruction
180fd697ecfSMasahiro Yamada */
readfr_extra_feature_reg(void)181fd697ecfSMasahiro Yamada static inline unsigned int readfr_extra_feature_reg(void)
182fd697ecfSMasahiro Yamada {
183fd697ecfSMasahiro Yamada unsigned int val;
184fd697ecfSMasahiro Yamada asm volatile ("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr" : "=r"
185fd697ecfSMasahiro Yamada (val) : : "cc");
186fd697ecfSMasahiro Yamada return val;
187fd697ecfSMasahiro Yamada }
188fd697ecfSMasahiro Yamada
189fd697ecfSMasahiro Yamada /*
190fd697ecfSMasahiro Yamada * write feroceon core extra feature register
191fd697ecfSMasahiro Yamada * using co-proc instruction
192fd697ecfSMasahiro Yamada */
writefr_extra_feature_reg(unsigned int val)193fd697ecfSMasahiro Yamada static inline void writefr_extra_feature_reg(unsigned int val)
194fd697ecfSMasahiro Yamada {
195fd697ecfSMasahiro Yamada asm volatile ("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr" : : "r"
196fd697ecfSMasahiro Yamada (val) : "cc");
197fd697ecfSMasahiro Yamada isb();
198fd697ecfSMasahiro Yamada }
199fd697ecfSMasahiro Yamada
200fd697ecfSMasahiro Yamada /*
201fd697ecfSMasahiro Yamada * AHB to Mbus Bridge Registers
202fd697ecfSMasahiro Yamada * Source: 88F5182 User Manual, Appendix A, section A.4
203fd697ecfSMasahiro Yamada * Note: only windows 0 and 1 have remap capability.
204fd697ecfSMasahiro Yamada */
205fd697ecfSMasahiro Yamada struct orion5x_win_registers {
206fd697ecfSMasahiro Yamada u32 ctrl;
207fd697ecfSMasahiro Yamada u32 base;
208fd697ecfSMasahiro Yamada u32 remap_lo;
209fd697ecfSMasahiro Yamada u32 remap_hi;
210fd697ecfSMasahiro Yamada };
211fd697ecfSMasahiro Yamada
212fd697ecfSMasahiro Yamada /*
213fd697ecfSMasahiro Yamada * CPU control and status Registers
214fd697ecfSMasahiro Yamada * Source: 88F5182 User Manual, Appendix A, section A.4
215fd697ecfSMasahiro Yamada */
216fd697ecfSMasahiro Yamada struct orion5x_cpu_registers {
217fd697ecfSMasahiro Yamada u32 config; /*0x20100 */
218fd697ecfSMasahiro Yamada u32 ctrl_stat; /*0x20104 */
219fd697ecfSMasahiro Yamada u32 rstoutn_mask; /* 0x20108 */
220fd697ecfSMasahiro Yamada u32 sys_soft_rst; /* 0x2010C */
221fd697ecfSMasahiro Yamada u32 ahb_mbus_cause_irq; /* 0x20110 */
222fd697ecfSMasahiro Yamada u32 ahb_mbus_mask_irq; /* 0x20114 */
223fd697ecfSMasahiro Yamada };
224fd697ecfSMasahiro Yamada
225fd697ecfSMasahiro Yamada /*
226fd697ecfSMasahiro Yamada * DDR SDRAM Controller Address Decode Registers
227fd697ecfSMasahiro Yamada * Source: 88F5182 User Manual, Appendix A, section A.5.1
228fd697ecfSMasahiro Yamada */
229fd697ecfSMasahiro Yamada struct orion5x_ddr_addr_decode_registers {
230fd697ecfSMasahiro Yamada u32 base;
231fd697ecfSMasahiro Yamada u32 size;
232fd697ecfSMasahiro Yamada };
233fd697ecfSMasahiro Yamada
234fd697ecfSMasahiro Yamada /*
235fd697ecfSMasahiro Yamada * functions
236fd697ecfSMasahiro Yamada */
237fd697ecfSMasahiro Yamada u32 orion5x_device_id(void);
238fd697ecfSMasahiro Yamada u32 orion5x_device_rev(void);
239fd697ecfSMasahiro Yamada unsigned int orion5x_winctrl_calcsize(unsigned int sizeval);
240fd697ecfSMasahiro Yamada void timer_init_r(void);
241fd697ecfSMasahiro Yamada #endif /* __ASSEMBLY__ */
242fd697ecfSMasahiro Yamada #endif /* _ORION5X_CPU_H */
243