mvwin.h (de7201225514f33f0fde51cab02f4a86c879b13d) mvwin.h (16694521fe80f54bf8f37334fe9a54bc5c953a6a)
1/*-
1/*-
2 * Copyright (C) 2007-2008 MARVELL INTERNATIONAL LTD.
2 * Copyright (C) 2007-2011 MARVELL INTERNATIONAL LTD.
3 * All rights reserved.
4 *
5 * Developed by Semihalf.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

30 *
31 * $FreeBSD$
32 */
33
34#ifndef _MVWIN_H_
35#define _MVWIN_H_
36
37/*
3 * All rights reserved.
4 *
5 * Developed by Semihalf.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

30 *
31 * $FreeBSD$
32 */
33
34#ifndef _MVWIN_H_
35#define _MVWIN_H_
36
37/*
38 * Physical addresses of integrated SoC peripherals
38 * Decode windows addresses.
39 *
40 * All decoding windows must be aligned to their size, which has to be
41 * a power of 2.
39 */
42 */
43
44/*
45 * SoC Integrated devices: 0xF1000000, 16 MB (VA == PA)
46 */
47
48/* SoC Regs */
40#define MV_PHYS_BASE 0xF1000000
49#define MV_PHYS_BASE 0xF1000000
41#define MV_SIZE 0x100000
50#define MV_SIZE (1024 * 1024) /* 1 MB */
42
51
52/* SRAM */
53#define MV_CESA_SRAM_BASE 0xF1100000
54
55/* AXI Regs */
56#ifdef SOC_MV_DOVE
57#define MV_AXI_PHYS_BASE 0xF1800000
58#define MV_AXI_BASE MV_AXI_PHYS_BASE
59#define MV_AXI_SIZE (16 * 1024 * 1024) /* 16 MB */
60#endif
61
43/*
62/*
44 * Decode windows addresses (physical)
63 * External devices: 0x80000000, 1 GB (VA == PA)
64 * Includes Device Bus, PCI and PCIE.
45 */
65 */
46#define MV_PCIE_IO_PHYS_BASE (MV_PHYS_BASE + MV_SIZE)
47#define MV_PCIE_IO_BASE MV_PCIE_IO_PHYS_BASE
48#define MV_PCIE_IO_SIZE (1024 * 1024)
49#define MV_PCI_IO_PHYS_BASE (MV_PCIE_IO_PHYS_BASE + MV_PCIE_IO_SIZE)
50#define MV_PCI_IO_BASE MV_PCI_IO_PHYS_BASE
51#define MV_PCI_IO_SIZE (1024 * 1024)
66#if defined(SOC_MV_ORION)
67#define MV_PCI_PORTS 2 /* 1x PCI + 1x PCIE */
68#elif defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_FREY)
69#define MV_PCI_PORTS 1 /* 1x PCIE */
70#elif defined(SOC_MV_DISCOVERY)
71#define MV_PCI_PORTS 8 /* 8x PCIE */
72#elif defined(SOC_MV_DOVE) || defined(SOC_MV_LOKIPLUS)
73#define MV_PCI_PORTS 2 /* 2x PCIE */
74#elif defined(SOC_MV_ARMADAXP)
75#define MV_PCI_PORTS 3 /* 3x PCIE */
76#else
77#error "MV_PCI_PORTS not configured !"
78#endif
52
79
53#define MV_PCIE_MEM_PHYS_BASE (MV_PCI_IO_PHYS_BASE + MV_PCI_IO_SIZE)
54#define MV_PCIE_MEM_BASE MV_PCIE_MEM_PHYS_BASE
55#define MV_PCIE_MEM_SIZE (64 * 1024 * 1024)
56#define MV_PCI_MEM_PHYS_BASE (MV_PCIE_MEM_PHYS_BASE + MV_PCIE_MEM_SIZE)
80/* PCI/PCIE Memory */
81#define MV_PCI_MEM_PHYS_BASE 0x80000000
82#define MV_PCI_MEM_SIZE (512 * 1024 * 1024) /* 512 MB */
57#define MV_PCI_MEM_BASE MV_PCI_MEM_PHYS_BASE
83#define MV_PCI_MEM_BASE MV_PCI_MEM_PHYS_BASE
58#define MV_PCI_MEM_SIZE (64 * 1024 * 1024)
84#define MV_PCI_MEM_SLICE_SIZE (MV_PCI_MEM_SIZE / MV_PCI_PORTS)
85#define MV_PCI_MEM_SLICE(n) (MV_PCI_MEM_BASE + ((n) * \
86 MV_PCI_MEM_SLICE_SIZE))
87/* PCI/PCIE I/O */
88#define MV_PCI_IO_PHYS_BASE 0xBF000000
89#define MV_PCI_IO_SIZE (16 * 1024 * 1024) /* 16 MB */
90#define MV_PCI_IO_BASE MV_PCI_IO_PHYS_BASE
91#define MV_PCI_IO_SLICE_SIZE (MV_PCI_IO_SIZE / MV_PCI_PORTS)
92#define MV_PCI_IO_SLICE(n) (MV_PCI_IO_BASE + ((n) * MV_PCI_IO_SLICE_SIZE))
59
93
60#define MV_DEV_BOOT_BASE 0xF9300000
61#define MV_DEV_BOOT_SIZE (1024 * 1024) /* 1 MB */
94#if defined(SOC_MV_FREY)
95#define MV_PCI_VA_MEM_BASE MV_PCI_MEM_BASE
96#else
97#define MV_PCI_VA_MEM_BASE 0
98#endif
99#define MV_PCI_VA_IO_BASE 0
62
100
63#define MV_DEV_CS0_BASE 0xF9400000
64#define MV_DEV_CS0_SIZE (1024 * 1024) /* 1 MB */
101/*
102 * Device Bus (VA == PA)
103 */
104#define MV_DEV_BOOT_BASE 0xF9300000
105#define MV_DEV_BOOT_SIZE (1024 * 1024) /* 1 MB */
65
106
66#define MV_DEV_CS1_BASE 0xF9500000
67#define MV_DEV_CS1_SIZE (32 * 1024 * 1024) /* 32 MB */
107#define MV_DEV_CS0_BASE 0xF9400000
108#define MV_DEV_CS0_SIZE (1024 * 1024) /* 1 MB */
68
109
69#define MV_DEV_CS2_BASE 0xFB500000
70#define MV_DEV_CS2_SIZE (1024 * 1024) /* 1 MB */
110#define MV_DEV_CS1_BASE 0xF9500000
111#define MV_DEV_CS1_SIZE (32 * 1024 * 1024) /* 32 MB */
71
112
72#define MV_CESA_SRAM_PHYS_BASE 0xFD000000
73#define MV_CESA_SRAM_BASE MV_CESA_SRAM_PHYS_BASE /* VA == PA mapping */
74#define MV_CESA_SRAM_SIZE (1024 * 1024)
113#define MV_DEV_CS2_BASE 0xFB500000
114#define MV_DEV_CS2_SIZE (1024 * 1024) /* 1 MB */
75
115
76/* XXX this is probably not robust against wraparounds... */
77#if ((MV_CESA_SRAM_PHYS_BASE + MV_CESA_SRAM_SIZE) > 0xFFFEFFFF)
78#error Devices memory layout overlaps reset vectors range!
79#endif
80
81/*
82 * Integrated SoC peripherals addresses
83 */
84#define MV_BASE MV_PHYS_BASE /* VA == PA mapping */
116
117/*
118 * Integrated SoC peripherals addresses
119 */
120#define MV_BASE MV_PHYS_BASE /* VA == PA mapping */
121#if defined(SOC_MV_DOVE)
122#define MV_DDR_CADR_BASE (MV_AXI_BASE + 0x100)
123#elif defined(SOC_MV_LOKIPLUS)
124#define MV_DDR_CADR_BASE (MV_BASE + 0xF1500)
125#else
85#define MV_DDR_CADR_BASE (MV_BASE + 0x1500)
126#define MV_DDR_CADR_BASE (MV_BASE + 0x1500)
127#endif
86#define MV_MPP_BASE (MV_BASE + 0x10000)
87
128#define MV_MPP_BASE (MV_BASE + 0x10000)
129
130#if defined(SOC_MV_ARMADAXP)
88#define MV_MBUS_BRIDGE_BASE (MV_BASE + 0x20000)
89#define MV_INTREGS_BASE (MV_MBUS_BRIDGE_BASE + 0x80)
131#define MV_MBUS_BRIDGE_BASE (MV_BASE + 0x20000)
132#define MV_INTREGS_BASE (MV_MBUS_BRIDGE_BASE + 0x80)
133#define MV_CPU_CONTROL_BASE (MV_MBUS_BRIDGE_BASE + 0x1800)
134#elif !defined(SOC_MV_FREY)
135#define MV_MBUS_BRIDGE_BASE (MV_BASE + 0x20000)
136#define MV_INTREGS_BASE (MV_MBUS_BRIDGE_BASE + 0x80)
90#define MV_CPU_CONTROL_BASE (MV_MBUS_BRIDGE_BASE + 0x100)
137#define MV_CPU_CONTROL_BASE (MV_MBUS_BRIDGE_BASE + 0x100)
138#else
139#define MV_CPU_CONTROL_BASE (MV_BASE + 0x10000)
140#endif
91
92#define MV_PCI_BASE (MV_BASE + 0x30000)
93#define MV_PCI_SIZE 0x2000
94
141
142#define MV_PCI_BASE (MV_BASE + 0x30000)
143#define MV_PCI_SIZE 0x2000
144
145#if defined(SOC_MV_FREY)
146#define MV_PCIE_BASE (MV_BASE + 0x8000)
147#else
95#define MV_PCIE_BASE (MV_BASE + 0x40000)
148#define MV_PCIE_BASE (MV_BASE + 0x40000)
149#endif
96#define MV_PCIE_SIZE 0x2000
97
98#define MV_PCIE00_BASE (MV_PCIE_BASE + 0x00000)
99#define MV_PCIE01_BASE (MV_PCIE_BASE + 0x04000)
100#define MV_PCIE02_BASE (MV_PCIE_BASE + 0x08000)
101#define MV_PCIE03_BASE (MV_PCIE_BASE + 0x0C000)
102#define MV_PCIE10_BASE (MV_PCIE_BASE + 0x40000)
103#define MV_PCIE11_BASE (MV_PCIE_BASE + 0x44000)
104#define MV_PCIE12_BASE (MV_PCIE_BASE + 0x48000)
105#define MV_PCIE13_BASE (MV_PCIE_BASE + 0x4C000)
106
150#define MV_PCIE_SIZE 0x2000
151
152#define MV_PCIE00_BASE (MV_PCIE_BASE + 0x00000)
153#define MV_PCIE01_BASE (MV_PCIE_BASE + 0x04000)
154#define MV_PCIE02_BASE (MV_PCIE_BASE + 0x08000)
155#define MV_PCIE03_BASE (MV_PCIE_BASE + 0x0C000)
156#define MV_PCIE10_BASE (MV_PCIE_BASE + 0x40000)
157#define MV_PCIE11_BASE (MV_PCIE_BASE + 0x44000)
158#define MV_PCIE12_BASE (MV_PCIE_BASE + 0x48000)
159#define MV_PCIE13_BASE (MV_PCIE_BASE + 0x4C000)
160
161#define MV_SDIO_BASE (MV_BASE + 0x90000)
162#define MV_SDIO_SIZE 0x10000
163
107/*
108 * Decode windows definitions and macros
109 */
164/*
165 * Decode windows definitions and macros
166 */
167#if defined(SOC_MV_ARMADAXP)
168#define MV_WIN_CPU_CTRL(n) (((n) < 8) ? 0x10 * (n) : 0x90 + (0x8 * ((n) - 8)))
169#define MV_WIN_CPU_BASE(n) ((((n) < 8) ? 0x10 * (n) : 0x90 + (0x8 * ((n) - 8))) + 0x4)
170#define MV_WIN_CPU_REMAP_LO(n) (0x10 * (n) + 0x008)
171#define MV_WIN_CPU_REMAP_HI(n) (0x10 * (n) + 0x00C)
172#else
110#define MV_WIN_CPU_CTRL(n) (0x10 * (n) + (((n) < 8) ? 0x000 : 0x880))
111#define MV_WIN_CPU_BASE(n) (0x10 * (n) + (((n) < 8) ? 0x004 : 0x884))
112#define MV_WIN_CPU_REMAP_LO(n) (0x10 * (n) + (((n) < 8) ? 0x008 : 0x888))
113#define MV_WIN_CPU_REMAP_HI(n) (0x10 * (n) + (((n) < 8) ? 0x00C : 0x88C))
173#define MV_WIN_CPU_CTRL(n) (0x10 * (n) + (((n) < 8) ? 0x000 : 0x880))
174#define MV_WIN_CPU_BASE(n) (0x10 * (n) + (((n) < 8) ? 0x004 : 0x884))
175#define MV_WIN_CPU_REMAP_LO(n) (0x10 * (n) + (((n) < 8) ? 0x008 : 0x888))
176#define MV_WIN_CPU_REMAP_HI(n) (0x10 * (n) + (((n) < 8) ? 0x00C : 0x88C))
177#endif
178
114#if defined(SOC_MV_DISCOVERY)
115#define MV_WIN_CPU_MAX 14
179#if defined(SOC_MV_DISCOVERY)
180#define MV_WIN_CPU_MAX 14
181#elif defined(SOC_MV_ARMADAXP)
182#define MV_WIN_CPU_MAX 20
116#else
117#define MV_WIN_CPU_MAX 8
118#endif
119
183#else
184#define MV_WIN_CPU_MAX 8
185#endif
186
187#define MV_WIN_CPU_ATTR_SHIFT 8
188#if defined(SOC_MV_LOKIPLUS)
189#define MV_WIN_CPU_TARGET_SHIFT 0
190#define MV_WIN_CPU_ENABLE_BIT (1 << 5)
191#else
192#define MV_WIN_CPU_TARGET_SHIFT 4
193#define MV_WIN_CPU_ENABLE_BIT 1
194#endif
195
196#if defined(SOC_MV_DOVE)
197#define MV_WIN_DDR_MAX 2
198#else /* SOC_MV_DOVE */
199#if defined(SOC_MV_LOKIPLUS)
200#define MV_WIN_DDR_BASE(n) (0xc * (n) + 0x4)
201#define MV_WIN_DDR_SIZE(n) (0xc * (n) + 0x0)
202#else /* SOC_MV_LOKIPLUS */
120#define MV_WIN_DDR_BASE(n) (0x8 * (n) + 0x0)
121#define MV_WIN_DDR_SIZE(n) (0x8 * (n) + 0x4)
203#define MV_WIN_DDR_BASE(n) (0x8 * (n) + 0x0)
204#define MV_WIN_DDR_SIZE(n) (0x8 * (n) + 0x4)
205#endif /* SOC_MV_LOKIPLUS */
122#define MV_WIN_DDR_MAX 4
206#define MV_WIN_DDR_MAX 4
207#endif /* SOC_MV_DOVE */
123
124#define MV_WIN_CESA_CTRL(n) (0x8 * (n) + 0xa04)
125#define MV_WIN_CESA_BASE(n) (0x8 * (n) + 0xa00)
126#define MV_WIN_CESA_MAX 4
127
128#if defined(SOC_MV_DISCOVERY)
129#define MV_WIN_CESA_TARGET 9
130#define MV_WIN_CESA_ATTR 1
131#else
132#define MV_WIN_CESA_TARGET 3
133#define MV_WIN_CESA_ATTR 0
134#endif
135
208
209#define MV_WIN_CESA_CTRL(n) (0x8 * (n) + 0xa04)
210#define MV_WIN_CESA_BASE(n) (0x8 * (n) + 0xa00)
211#define MV_WIN_CESA_MAX 4
212
213#if defined(SOC_MV_DISCOVERY)
214#define MV_WIN_CESA_TARGET 9
215#define MV_WIN_CESA_ATTR 1
216#else
217#define MV_WIN_CESA_TARGET 3
218#define MV_WIN_CESA_ATTR 0
219#endif
220
136#define MV_WIN_USB_CTRL(n) (0x10 * (n) + 0x0)
137#define MV_WIN_USB_BASE(n) (0x10 * (n) + 0x4)
221#define MV_WIN_USB_CTRL(n) (0x10 * (n) + 0x320)
222#define MV_WIN_USB_BASE(n) (0x10 * (n) + 0x324)
138#define MV_WIN_USB_MAX 4
139
140#define MV_WIN_ETH_BASE(n) (0x8 * (n) + 0x200)
141#define MV_WIN_ETH_SIZE(n) (0x8 * (n) + 0x204)
142#define MV_WIN_ETH_REMAP(n) (0x4 * (n) + 0x280)
143#define MV_WIN_ETH_MAX 6
144
145#define MV_WIN_IDMA_BASE(n) (0x8 * (n) + 0xa00)

--- 7 unchanged lines hidden (view full) ---

153#define MV_WIN_XOR_SIZE(n, m) (0x4 * (n) + 0xa70 + (m) * 0x100)
154#define MV_WIN_XOR_REMAP(n, m) (0x4 * (n) + 0xa90 + (m) * 0x100)
155#define MV_WIN_XOR_CTRL(n, m) (0x4 * (n) + 0xa40 + (m) * 0x100)
156#define MV_WIN_XOR_OVERR(n, m) (0x4 * (n) + 0xaa0 + (m) * 0x100)
157#define MV_WIN_XOR_MAX 8
158#define MV_XOR_CHAN_MAX 2
159#define MV_XOR_NON_REMAP 4
160
223#define MV_WIN_USB_MAX 4
224
225#define MV_WIN_ETH_BASE(n) (0x8 * (n) + 0x200)
226#define MV_WIN_ETH_SIZE(n) (0x8 * (n) + 0x204)
227#define MV_WIN_ETH_REMAP(n) (0x4 * (n) + 0x280)
228#define MV_WIN_ETH_MAX 6
229
230#define MV_WIN_IDMA_BASE(n) (0x8 * (n) + 0xa00)

--- 7 unchanged lines hidden (view full) ---

238#define MV_WIN_XOR_SIZE(n, m) (0x4 * (n) + 0xa70 + (m) * 0x100)
239#define MV_WIN_XOR_REMAP(n, m) (0x4 * (n) + 0xa90 + (m) * 0x100)
240#define MV_WIN_XOR_CTRL(n, m) (0x4 * (n) + 0xa40 + (m) * 0x100)
241#define MV_WIN_XOR_OVERR(n, m) (0x4 * (n) + 0xaa0 + (m) * 0x100)
242#define MV_WIN_XOR_MAX 8
243#define MV_XOR_CHAN_MAX 2
244#define MV_XOR_NON_REMAP 4
245
161#if defined(SOC_MV_DISCOVERY)
162#define MV_WIN_PCIE_MEM_TARGET 4
163#define MV_WIN_PCIE_MEM_ATTR 0xE8
164#define MV_WIN_PCIE_IO_TARGET 4
165#define MV_WIN_PCIE_IO_ATTR 0xE0
166#elif defined(SOC_MV_KIRKWOOD)
167#define MV_WIN_PCIE_MEM_TARGET 4
168#define MV_WIN_PCIE_MEM_ATTR 0xE8
169#define MV_WIN_PCIE_IO_TARGET 4
170#define MV_WIN_PCIE_IO_ATTR 0xE0
246#if defined(SOC_MV_DISCOVERY) || defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DOVE)
247#define MV_WIN_PCIE_TARGET(n) 4
248#define MV_WIN_PCIE_MEM_ATTR(n) 0xE8
249#define MV_WIN_PCIE_IO_ATTR(n) 0xE0
250#elif defined(SOC_MV_ARMADAXP)
251#define MV_WIN_PCIE_TARGET(n) (4 + (4 * ((n) % 2)))
252#define MV_WIN_PCIE_MEM_ATTR(n) (0xE8 + (0x10 * ((n) / 2)))
253#define MV_WIN_PCIE_IO_ATTR(n) (0xE0 + (0x10 * ((n) / 2)))
171#elif defined(SOC_MV_ORION)
254#elif defined(SOC_MV_ORION)
172#define MV_WIN_PCIE_MEM_TARGET 4
173#define MV_WIN_PCIE_MEM_ATTR 0x59
174#define MV_WIN_PCIE_IO_TARGET 4
175#define MV_WIN_PCIE_IO_ATTR 0x51
176#define MV_WIN_PCI_MEM_TARGET 3
255#define MV_WIN_PCIE_TARGET(n) 4
256#define MV_WIN_PCIE_MEM_ATTR(n) 0x59
257#define MV_WIN_PCIE_IO_ATTR(n) 0x51
258#define MV_WIN_PCI_TARGET 3
177#define MV_WIN_PCI_MEM_ATTR 0x59
259#define MV_WIN_PCI_MEM_ATTR 0x59
178#define MV_WIN_PCI_IO_TARGET 3
179#define MV_WIN_PCI_IO_ATTR 0x51
260#define MV_WIN_PCI_IO_ATTR 0x51
261#elif defined(SOC_MV_LOKIPLUS)
262#define MV_WIN_PCIE_TARGET(n) (3 + (n))
263#define MV_WIN_PCIE_MEM_ATTR(n) 0x59
264#define MV_WIN_PCIE_IO_ATTR(n) 0x51
180#endif
181
182#define MV_WIN_PCIE_CTRL(n) (0x10 * (((n) < 5) ? (n) : \
183 (n) + 1) + 0x1820)
184#define MV_WIN_PCIE_BASE(n) (0x10 * (((n) < 5) ? (n) : \
185 (n) + 1) + 0x1824)
186#define MV_WIN_PCIE_REMAP(n) (0x10 * (((n) < 5) ? (n) : \
187 (n) + 1) + 0x182C)
188#define MV_WIN_PCIE_MAX 6
189
265#endif
266
267#define MV_WIN_PCIE_CTRL(n) (0x10 * (((n) < 5) ? (n) : \
268 (n) + 1) + 0x1820)
269#define MV_WIN_PCIE_BASE(n) (0x10 * (((n) < 5) ? (n) : \
270 (n) + 1) + 0x1824)
271#define MV_WIN_PCIE_REMAP(n) (0x10 * (((n) < 5) ? (n) : \
272 (n) + 1) + 0x182C)
273#define MV_WIN_PCIE_MAX 6
274
190#define MV_PCIE_BAR(n) (0x04 * (n) + 0x1804)
191#define MV_PCIE_BAR_MAX 3
275#define MV_PCIE_BAR_CTRL(n) (0x04 * (n) + 0x1800)
276#define MV_PCIE_BAR_BASE(n) (0x08 * ((n) < 3 ? (n) : 4) + 0x0010)
277#define MV_PCIE_BAR_BASE_H(n) (0x08 * (n) + 0x0014)
278#define MV_PCIE_BAR_MAX 4
279#define MV_PCIE_BAR_64BIT (0x4)
280#define MV_PCIE_BAR_PREFETCH_EN (0x8)
192
281
282#define MV_PCIE_CONTROL (0x1a00)
283#define MV_PCIE_ROOT_CMPLX (1 << 1)
284
193#define MV_WIN_SATA_CTRL(n) (0x10 * (n) + 0x30)
194#define MV_WIN_SATA_BASE(n) (0x10 * (n) + 0x34)
195#define MV_WIN_SATA_MAX 4
196
197#define WIN_REG_IDX_RD(pre,reg,off,base) \
198 static __inline uint32_t \
199 pre ## _ ## reg ## _read(int i) \
200 { \

--- 81 unchanged lines hidden ---
285#define MV_WIN_SATA_CTRL(n) (0x10 * (n) + 0x30)
286#define MV_WIN_SATA_BASE(n) (0x10 * (n) + 0x34)
287#define MV_WIN_SATA_MAX 4
288
289#define WIN_REG_IDX_RD(pre,reg,off,base) \
290 static __inline uint32_t \
291 pre ## _ ## reg ## _read(int i) \
292 { \

--- 81 unchanged lines hidden ---