1 /***********************license start***************
2 * Author: Cavium Networks
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
7 * Copyright (c) 2003-2009 Cavium Networks
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
29 * Typedefs and defines for working with Octeon physical addresses.
32 #ifndef __CVMX_ADDRESS_H__
33 #define __CVMX_ADDRESS_H__
37 CVMX_MIPS_SPACE_XKSEG
= 3LL,
38 CVMX_MIPS_SPACE_XKPHYS
= 2LL,
39 CVMX_MIPS_SPACE_XSSEG
= 1LL,
40 CVMX_MIPS_SPACE_XUSEG
= 0LL
45 CVMX_MIPS_XKSEG_SPACE_KSEG0
= 0LL,
46 CVMX_MIPS_XKSEG_SPACE_KSEG1
= 1LL,
47 CVMX_MIPS_XKSEG_SPACE_SSEG
= 2LL,
48 CVMX_MIPS_XKSEG_SPACE_KSEG3
= 3LL
49 } cvmx_mips_xkseg_space_t
;
51 /* decodes <14:13> of a kseg3 window address */
53 CVMX_ADD_WIN_SCR
= 0L,
54 /* see cvmx_add_win_dma_dec_t for further decode */
55 CVMX_ADD_WIN_DMA
= 1L,
56 CVMX_ADD_WIN_UNUSED
= 2L,
57 CVMX_ADD_WIN_UNUSED2
= 3L
60 /* decode within DMA space */
63 * Add store data to the write buffer entry, allocating it if
66 CVMX_ADD_WIN_DMA_ADD
= 0L,
67 /* send out the write buffer entry to DRAM */
68 CVMX_ADD_WIN_DMA_SENDMEM
= 1L,
69 /* store data must be normal DRAM memory space address in this case */
70 /* send out the write buffer entry as an IOBDMA command */
71 CVMX_ADD_WIN_DMA_SENDDMA
= 2L,
72 /* see CVMX_ADD_WIN_DMA_SEND_DEC for data contents */
73 /* send out the write buffer entry as an IO write */
74 CVMX_ADD_WIN_DMA_SENDIO
= 3L,
75 /* store data must be normal IO space address in this case */
76 /* send out a single-tick command on the NCB bus */
77 CVMX_ADD_WIN_DMA_SENDSINGLE
= 4L,
78 /* no write buffer data needed/used */
79 } cvmx_add_win_dma_dec_t
;
82 * Physical Address Decode
84 * Octeon-I HW never interprets this X (<39:36> reserved
85 * for future expansion), software should set to 0.
87 * - 0x0 XXX0 0000 0000 to DRAM Cached
88 * - 0x0 XXX0 0FFF FFFF
90 * - 0x0 XXX0 1000 0000 to Boot Bus Uncached (Converted to 0x1 00X0 1000 0000
91 * - 0x0 XXX0 1FFF FFFF + EJTAG to 0x1 00X0 1FFF FFFF)
93 * - 0x0 XXX0 2000 0000 to DRAM Cached
94 * - 0x0 XXXF FFFF FFFF
96 * - 0x1 00X0 0000 0000 to Boot Bus Uncached
97 * - 0x1 00XF FFFF FFFF
99 * - 0x1 01X0 0000 0000 to Other NCB Uncached
100 * - 0x1 FFXF FFFF FFFF devices
102 * Decode of all Octeon addresses
107 #ifdef __BIG_ENDIAN_BITFIELD
108 /* mapped or unmapped virtual address */
114 /* mapped USEG virtual addresses (typically) */
120 /* mapped or unmapped virtual address */
128 * physical address accessed through xkphys unmapped virtual
132 uint64_t R
:2; /* CVMX_MIPS_SPACE_XKPHYS in this case */
133 uint64_t cca
:3; /* ignored by octeon */
135 uint64_t pa
:49; /* physical address */
138 /* physical address */
141 /* if set, the address is uncached and resides on MCB bus */
144 * the hardware ignores this field when is_io==0, else
148 /* the hardware ignores <39:36> in Octeon I */
153 /* physical mem address */
155 /* techically, <47:40> are dont-cares */
157 /* the hardware ignores <39:36> in Octeon I */
162 /* physical IO address */
164 uint64_t mem_region
:2;
169 * The hardware ignores this field when is_io==0, else
173 /* the hardware ignores <39:36> in Octeon I */
179 * Scratchpad virtual address - accessed through a window at
184 /* CVMX_ADD_WIN_SCR (0) in this case */
185 cvmx_add_win_dec_t csrdec
:2;
189 /* there should only be stores to IOBDMA space, no loads */
191 * IOBDMA virtual address - accessed through a window at the
196 uint64_t csrdec
:2; /* CVMX_ADD_WIN_DMA (1) in this case */
203 uint64_t didspace
:24;
250 uint64_t mem_region
:2;
255 cvmx_add_win_dec_t csrdec
:2;
269 uint64_t didspace
:24;
275 /* These macros for used by 32 bit applications */
277 #define CVMX_MIPS32_SPACE_KSEG0 1l
278 #define CVMX_ADD_SEG32(segment, add) \
279 (((int32_t)segment << 31) | (int32_t)(add))
282 * Currently all IOs are performed using XKPHYS addressing. Linux uses
283 * the CvmMemCtl register to enable XKPHYS addressing to IO space from
284 * user mode. Future OSes may need to change the upper bits of IO
285 * addresses. The following define controls the upper two bits for all
286 * IO addresses generated by the simple executive library.
288 #define CVMX_IO_SEG CVMX_MIPS_SPACE_XKPHYS
290 /* These macros simplify the process of creating common IO addresses */
291 #define CVMX_ADD_SEG(segment, add) ((((uint64_t)segment) << 62) | (add))
292 #ifndef CVMX_ADD_IO_SEG
293 #define CVMX_ADD_IO_SEG(add) CVMX_ADD_SEG(CVMX_IO_SEG, (add))
295 #define CVMX_ADDR_DIDSPACE(did) (((CVMX_IO_SEG) << 22) | ((1ULL) << 8) | (did))
296 #define CVMX_ADDR_DID(did) (CVMX_ADDR_DIDSPACE(did) << 40)
297 #define CVMX_FULL_DID(did, subdid) (((did) << 3) | (subdid))
299 /* from include/ncb_rsl_id.v */
300 #define CVMX_OCT_DID_MIS 0ULL /* misc stuff */
301 #define CVMX_OCT_DID_GMX0 1ULL
302 #define CVMX_OCT_DID_GMX1 2ULL
303 #define CVMX_OCT_DID_PCI 3ULL
304 #define CVMX_OCT_DID_KEY 4ULL
305 #define CVMX_OCT_DID_FPA 5ULL
306 #define CVMX_OCT_DID_DFA 6ULL
307 #define CVMX_OCT_DID_ZIP 7ULL
308 #define CVMX_OCT_DID_RNG 8ULL
309 #define CVMX_OCT_DID_IPD 9ULL
310 #define CVMX_OCT_DID_PKT 10ULL
311 #define CVMX_OCT_DID_TIM 11ULL
312 #define CVMX_OCT_DID_TAG 12ULL
313 /* the rest are not on the IO bus */
314 #define CVMX_OCT_DID_L2C 16ULL
315 #define CVMX_OCT_DID_LMC 17ULL
316 #define CVMX_OCT_DID_SPX0 18ULL
317 #define CVMX_OCT_DID_SPX1 19ULL
318 #define CVMX_OCT_DID_PIP 20ULL
319 #define CVMX_OCT_DID_ASX0 22ULL
320 #define CVMX_OCT_DID_ASX1 23ULL
321 #define CVMX_OCT_DID_IOB 30ULL
323 #define CVMX_OCT_DID_PKT_SEND CVMX_FULL_DID(CVMX_OCT_DID_PKT, 2ULL)
324 #define CVMX_OCT_DID_TAG_SWTAG CVMX_FULL_DID(CVMX_OCT_DID_TAG, 0ULL)
325 #define CVMX_OCT_DID_TAG_TAG1 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 1ULL)
326 #define CVMX_OCT_DID_TAG_TAG2 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 2ULL)
327 #define CVMX_OCT_DID_TAG_TAG3 CVMX_FULL_DID(CVMX_OCT_DID_TAG, 3ULL)
328 #define CVMX_OCT_DID_TAG_NULL_RD CVMX_FULL_DID(CVMX_OCT_DID_TAG, 4ULL)
329 #define CVMX_OCT_DID_TAG_CSR CVMX_FULL_DID(CVMX_OCT_DID_TAG, 7ULL)
330 #define CVMX_OCT_DID_FAU_FAI CVMX_FULL_DID(CVMX_OCT_DID_IOB, 0ULL)
331 #define CVMX_OCT_DID_TIM_CSR CVMX_FULL_DID(CVMX_OCT_DID_TIM, 0ULL)
332 #define CVMX_OCT_DID_KEY_RW CVMX_FULL_DID(CVMX_OCT_DID_KEY, 0ULL)
333 #define CVMX_OCT_DID_PCI_6 CVMX_FULL_DID(CVMX_OCT_DID_PCI, 6ULL)
334 #define CVMX_OCT_DID_MIS_BOO CVMX_FULL_DID(CVMX_OCT_DID_MIS, 0ULL)
335 #define CVMX_OCT_DID_PCI_RML CVMX_FULL_DID(CVMX_OCT_DID_PCI, 0ULL)
336 #define CVMX_OCT_DID_IPD_CSR CVMX_FULL_DID(CVMX_OCT_DID_IPD, 7ULL)
337 #define CVMX_OCT_DID_DFA_CSR CVMX_FULL_DID(CVMX_OCT_DID_DFA, 7ULL)
338 #define CVMX_OCT_DID_MIS_CSR CVMX_FULL_DID(CVMX_OCT_DID_MIS, 7ULL)
339 #define CVMX_OCT_DID_ZIP_CSR CVMX_FULL_DID(CVMX_OCT_DID_ZIP, 0ULL)
341 #endif /* __CVMX_ADDRESS_H__ */