1215976Sjmallett/***********************license start***************
2232812Sjmallett * Copyright (c) 2003-2011  Cavium Inc. (support@cavium.com). All rights
3215976Sjmallett * reserved.
4215976Sjmallett *
5215976Sjmallett *
6215976Sjmallett * Redistribution and use in source and binary forms, with or without
7215976Sjmallett * modification, are permitted provided that the following conditions are
8215976Sjmallett * met:
9215976Sjmallett *
10215976Sjmallett *   * Redistributions of source code must retain the above copyright
11215976Sjmallett *     notice, this list of conditions and the following disclaimer.
12215976Sjmallett *
13215976Sjmallett *   * Redistributions in binary form must reproduce the above
14215976Sjmallett *     copyright notice, this list of conditions and the following
15215976Sjmallett *     disclaimer in the documentation and/or other materials provided
16215976Sjmallett *     with the distribution.
17215976Sjmallett
18232812Sjmallett *   * Neither the name of Cavium Inc. nor the names of
19215976Sjmallett *     its contributors may be used to endorse or promote products
20215976Sjmallett *     derived from this software without specific prior written
21215976Sjmallett *     permission.
22215976Sjmallett
23215976Sjmallett * This Software, including technical data, may be subject to U.S. export  control
24215976Sjmallett * laws, including the U.S. Export Administration Act and its  associated
25215976Sjmallett * regulations, and may be subject to export or import  regulations in other
26215976Sjmallett * countries.
27215976Sjmallett
28215976Sjmallett * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29232812Sjmallett * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30215976Sjmallett * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31215976Sjmallett * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32215976Sjmallett * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33215976Sjmallett * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34215976Sjmallett * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35215976Sjmallett * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36215976Sjmallett * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37215976Sjmallett * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38215976Sjmallett ***********************license end**************************************/
39215976Sjmallett
40215976Sjmallett
41215976Sjmallett
42215976Sjmallett/**
43215976Sjmallett * @file
44215976Sjmallett *
45215976Sjmallett * Interface to Octeon boot structure
46215976Sjmallett *
47215976Sjmallett * <hr>$Revision:  $<hr>
48215976Sjmallett */
49215976Sjmallett
50215976Sjmallett#ifndef __OCTEON_BOOT_INFO_H__
51215976Sjmallett#define __OCTEON_BOOT_INFO_H__
52215976Sjmallett
53215976Sjmallett#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
54215976Sjmallett#include <linux/types.h>
55232812Sjmallett#include <asm/octeon/cvmx-asm.h>
56232812Sjmallett#else
57232812Sjmallett#include "cvmx-asm.h"
58215976Sjmallett#endif
59215976Sjmallett
60215976Sjmallett#ifndef __ASSEMBLY__
61215976Sjmallett
62215976Sjmallett/*
63215976Sjmallett * This structure is access by bootloader, Linux kernel and the Linux
64215976Sjmallett * user space utility "bootoct".
65215976Sjmallett
66215976Sjmallett * In the bootloader, this structure is accessed by assembly code in start.S,
67215976Sjmallett * so any changes to content or size must be reflected there as well.
68215976Sjmallett
69215976Sjmallett * This is placed at a fixed address in DRAM, so that cores can access it
70215976Sjmallett * when they come out of reset.  It is used to setup the minimal bootloader
71215976Sjmallett * runtime environment (stack, but no heap, global data ptr) that is needed
72215976Sjmallett * by the non-boot cores to setup the environment for the applications.
73215976Sjmallett * The boot_info_addr is the address of a boot_info_block_t structure
74215976Sjmallett * which contains more core-specific information.
75215976Sjmallett *
76215976Sjmallett * The Linux kernel and the Linux bootoct utility access this structure for
77215976Sjmallett * implementing CPU hotplug functionality and booting of idle cores with SE
78215976Sjmallett * apps respectively.
79215976Sjmallett *
80215976Sjmallett */
81215976Sjmalletttypedef struct
82215976Sjmallett{
83215976Sjmallett    /* First stage address - in ram instead of flash */
84215976Sjmallett    uint64_t code_addr;
85215976Sjmallett    /* Setup code for application, NOT application entry point */
86215976Sjmallett    uint32_t app_start_func_addr;
87215976Sjmallett    /* k0 is used for global data - needs to be passed to other cores */
88215976Sjmallett    uint32_t k0_val;
89215976Sjmallett    /* Address of boot info block structure */
90215976Sjmallett    uint64_t boot_info_addr;
91215976Sjmallett    uint32_t flags;         /* flags */
92215976Sjmallett    uint32_t pad;
93215976Sjmallett} boot_init_vector_t;
94215976Sjmallett
95232812Sjmallett#if defined(__ASM_GBL_DATA_H)  /* defined above */
96215976Sjmallett/*
97232812Sjmallett * Definition of a data structure to mimic the old u-boot gd_t data structure.
98232812Sjmallett */
99232812Sjmallett#undef GD_TMP_STR_SIZE
100232812Sjmallett#define GD_TMP_STR_SIZE 32
101232812Sjmallett
102232812Sjmallett#define LINUX_APP_GLOBAL_DATA_MAGIC	0x221eb111476f410full
103232812Sjmallett#define LINUX_APP_GLOBAL_DATA_VERSION	2
104232812Sjmallett
105232812Sjmallettstruct linux_app_global_data {
106232812Sjmallett    bd_t		*bd;
107232812Sjmallett    unsigned long	flags;
108232812Sjmallett    unsigned long	baudrate;
109232812Sjmallett    unsigned long	have_console;	/* serial_init() was called */
110232812Sjmallett    uint64_t		ram_size;	/* RAM size */
111232812Sjmallett    uint64_t		reloc_off;	/* Relocation Offset */
112232812Sjmallett    unsigned long	env_addr;	/* Address  of Environment struct */
113232812Sjmallett    unsigned long	env_valid;	/* Checksum of Environment valid? */
114232812Sjmallett    unsigned long	cpu_clock_mhz;	/* CPU clock speed in MHz */
115232812Sjmallett    unsigned long	ddr_clock_mhz;	/* DDR clock (not data rate!) in MHz */
116232812Sjmallett    unsigned long	ddr_ref_hertz;	/* DDR Ref clock Hertz */
117232812Sjmallett    int			mcu_rev_maj;
118232812Sjmallett    int			mcu_rev_min;
119232812Sjmallett    int			console_uart;
120232812Sjmallett
121232812Sjmallett    /* EEPROM data structures as read from EEPROM or populated by other
122232812Sjmallett     * means on boards without an EEPROM
123232812Sjmallett     */
124232812Sjmallett    octeon_eeprom_board_desc_t	board_desc;
125232812Sjmallett    octeon_eeprom_clock_desc_t	clock_desc;
126232812Sjmallett    octeon_eeprom_mac_addr_t	mac_desc;
127232812Sjmallett
128232812Sjmallett    void		**jt;		/* jump table, not used */
129232812Sjmallett    char		*err_msg;	/* pointer to error message to save
130232812Sjmallett					 * until console is up.  Not used.
131232812Sjmallett					 */
132232812Sjmallett    union {
133232812Sjmallett        struct {	/* Keep under 32 bytes! */
134232812Sjmallett            uint64_t	magic;
135232812Sjmallett	    uint32_t	version;
136232812Sjmallett	    uint32_t	fdt_addr;
137232812Sjmallett        };
138232812Sjmallett        char		tmp_str[GD_TMP_STR_SIZE];
139232812Sjmallett    };
140232812Sjmallett    unsigned long	uboot_flash_address;	/* Address of normal bootloader
141232812Sjmallett						 * in flash
142232812Sjmallett						 */
143232812Sjmallett    unsigned long	uboot_flash_size;	/* Size of normal bootloader */
144232812Sjmallett    uint64_t		dfm_ram_size;	/* DFM RAM size */
145232812Sjmallett};
146232812Sjmalletttypedef struct linux_app_global_data linux_app_global_data_t;
147232812Sjmallett
148232812Sjmallett/* Flags for linux_app_global_data */
149232812Sjmallett#define LA_GD_FLG_RELOC			0x0001	/* Code was relocated to RAM	 */
150232812Sjmallett#define LA_GD_FLG_DEVINIT		0x0002	/* Devices have been initialized */
151232812Sjmallett#define LA_GD_FLG_SILENT		0x0004	/* Silent mode			 */
152232812Sjmallett#define LA_GD_FLG_CLOCK_DESC_MISSING	0x0008
153232812Sjmallett#define LA_GD_FLG_BOARD_DESC_MISSING	0x0010
154232812Sjmallett#define LA_GD_FLG_DDR_VERBOSE		0x0020
155232812Sjmallett#define LA_GD_FLG_DDR0_CLK_INITIALIZED	0x0040
156232812Sjmallett#define LA_GD_FLG_DDR1_CLK_INITIALIZED	0x0080
157232812Sjmallett#define LA_GD_FLG_DDR2_CLK_INITIALIZED	0x0100
158232812Sjmallett#define LA_GD_FLG_DDR3_CLK_INITIALIZED  0x0200
159232812Sjmallett#define LA_GD_FLG_FAILSAFE_MODE		0x0400	/* Use failsafe mode */
160232812Sjmallett#define LA_GD_FLG_DDR_TRACE_INIT	0x0800
161232812Sjmallett#define LA_GD_FLG_DFM_CLK_INITIALIZED	0x1000
162232812Sjmallett#define LA_GD_FLG_DFM_VERBOSE		0x2000
163232812Sjmallett#define LA_GD_FLG_DFM_TRACE_INIT	0x4000
164232812Sjmallett#define LA_GD_FLG_MEMORY_PRESERVED	0x8000
165232812Sjmallett#define LA_GD_FLG_RAM_RESIDENT		0x10000	/* RAM boot detected */
166232812Sjmallett#endif /* __ASM_GBL_DATA_H */
167232812Sjmallett
168232812Sjmallett/*
169215976Sjmallett * Definition of a data structure setup by the bootloader to enable Linux to
170215976Sjmallett * launch SE apps on idle cores.
171215976Sjmallett */
172215976Sjmallett
173215976Sjmallettstruct linux_app_boot_info
174215976Sjmallett{
175215976Sjmallett    uint32_t labi_signature;
176215976Sjmallett    uint32_t start_core0_addr;
177215976Sjmallett    uint32_t avail_coremask;
178215976Sjmallett    uint32_t pci_console_active;
179215976Sjmallett    uint32_t icache_prefetch_disable;
180215976Sjmallett    uint64_t InitTLBStart_addr;
181215976Sjmallett    uint32_t start_app_addr;
182215976Sjmallett    uint32_t cur_exception_base;
183215976Sjmallett    uint32_t no_mark_private_data;
184215976Sjmallett    uint32_t compact_flash_common_base_addr;
185215976Sjmallett    uint32_t compact_flash_attribute_base_addr;
186215976Sjmallett    uint32_t led_display_base_addr;
187232812Sjmallett#if defined(__ASM_GBL_DATA_H)  /* defined above */
188232812Sjmallett    linux_app_global_data_t gd;
189215976Sjmallett#endif
190215976Sjmallett};
191215976Sjmalletttypedef struct linux_app_boot_info linux_app_boot_info_t;
192215976Sjmallett
193215976Sjmallett#endif
194215976Sjmallett
195215976Sjmallett/* If not to copy a lot of bootloader's structures
196215976Sjmallett   here is only offset of requested member */
197215976Sjmallett#define AVAIL_COREMASK_OFFSET_IN_LINUX_APP_BOOT_BLOCK    0x765c
198215976Sjmallett
199215976Sjmallett/* hardcoded in bootloader */
200215976Sjmallett#define LABI_ADDR_IN_BOOTLOADER                         0x700
201215976Sjmallett
202215976Sjmallett#define LINUX_APP_BOOT_BLOCK_NAME "linux-app-boot"
203215976Sjmallett
204215976Sjmallett#define LABI_SIGNATURE 0xAABBCC01
205215976Sjmallett
206215976Sjmallett/*  from uboot-headers/octeon_mem_map.h */
207232812Sjmallett#if defined(CVMX_BUILD_FOR_LINUX_KERNEL) || defined(CVMX_BUILD_FOR_TOOLCHAIN)
208215976Sjmallett#define EXCEPTION_BASE_INCR     (4 * 1024)
209215976Sjmallett#endif
210215976Sjmallett
211215976Sjmallett/* Increment size for exception base addresses (4k minimum) */
212215976Sjmallett#define EXCEPTION_BASE_BASE     0
213215976Sjmallett#define BOOTLOADER_PRIV_DATA_BASE        (EXCEPTION_BASE_BASE + 0x800)
214215976Sjmallett#define BOOTLOADER_BOOT_VECTOR           (BOOTLOADER_PRIV_DATA_BASE)
215215976Sjmallett#define BOOTLOADER_DEBUG_TRAMPOLINE      (BOOTLOADER_BOOT_VECTOR + BOOT_VECTOR_SIZE)   /* WORD */
216215976Sjmallett#define BOOTLOADER_DEBUG_TRAMPOLINE_CORE (BOOTLOADER_DEBUG_TRAMPOLINE + 4)   /* WORD */
217215976Sjmallett
218232812Sjmallett#define OCTEON_EXCEPTION_VECTOR_BLOCK_SIZE  (CVMX_MAX_CORES*EXCEPTION_BASE_INCR) /* 32 4k blocks */
219215976Sjmallett#define BOOTLOADER_DEBUG_REG_SAVE_BASE  (EXCEPTION_BASE_BASE + OCTEON_EXCEPTION_VECTOR_BLOCK_SIZE)
220215976Sjmallett
221215976Sjmallett#define BOOT_VECTOR_NUM_WORDS           (8)
222232812Sjmallett#define BOOT_VECTOR_SIZE                ((CVMX_MAX_CORES*4)*BOOT_VECTOR_NUM_WORDS)
223215976Sjmallett
224215976Sjmallett
225215976Sjmallett#endif /* __OCTEON_BOOT_INFO_H__ */
226