Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 1 | /* |
Bernhard Nortmann | c9e8961 | 2015-09-17 18:52:50 +0200 | [diff] [blame] | 2 | * (C) Copyright 2007-2011 |
| 3 | * Allwinner Technology Co., Ltd. <www.allwinnertech.com> |
| 4 | * Tom Cubie <tangliang@allwinnertech.com> |
Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | #ifndef _ASM_ARCH_SPL_H_ |
Jeroen Hofstee | c5d88a5 | 2014-06-11 22:01:48 +0200 | [diff] [blame] | 9 | #define _ASM_ARCH_SPL_H_ |
Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 10 | |
Bernhard Nortmann | c9e8961 | 2015-09-17 18:52:50 +0200 | [diff] [blame] | 11 | #define BOOT0_MAGIC "eGON.BT0" |
Bernhard Nortmann | 01ad493 | 2015-09-17 18:52:51 +0200 | [diff] [blame] | 12 | #define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */ |
| 13 | #define SPL_HEADER_VERSION 1 |
Bernhard Nortmann | c9e8961 | 2015-09-17 18:52:50 +0200 | [diff] [blame] | 14 | |
Siarhei Siamashka | 26c50fb | 2016-03-29 17:29:10 +0200 | [diff] [blame] | 15 | #if defined(CONFIG_MACH_SUN9I) || defined(CONFIG_MACH_SUN50I) |
| 16 | #define SPL_ADDR 0x10000 |
| 17 | #else |
Bernhard Nortmann | ead498a | 2015-09-17 18:52:52 +0200 | [diff] [blame] | 18 | #define SPL_ADDR 0x0 |
Siarhei Siamashka | 26c50fb | 2016-03-29 17:29:10 +0200 | [diff] [blame] | 19 | #endif |
Bernhard Nortmann | ead498a | 2015-09-17 18:52:52 +0200 | [diff] [blame] | 20 | |
Siarhei Siamashka | 08e978b | 2016-05-14 04:13:26 +0300 | [diff] [blame] | 21 | /* The low 8-bits of the 'boot_media' field in the SPL header */ |
| 22 | #define SUNXI_BOOTED_FROM_MMC0 0 |
| 23 | #define SUNXI_BOOTED_FROM_SPI 3 |
| 24 | |
Bernhard Nortmann | c9e8961 | 2015-09-17 18:52:50 +0200 | [diff] [blame] | 25 | /* boot head definition from sun4i boot code */ |
| 26 | struct boot_file_head { |
| 27 | uint32_t b_instruction; /* one intruction jumping to real code */ |
| 28 | uint8_t magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */ |
| 29 | uint32_t check_sum; /* generated by PC */ |
| 30 | uint32_t length; /* generated by PC */ |
| 31 | /* |
| 32 | * We use a simplified header, only filling in what is needed |
| 33 | * by the boot ROM. To be compatible with Allwinner tools we |
| 34 | * would need to implement the proper fields here instead of |
| 35 | * padding. |
Bernhard Nortmann | 01ad493 | 2015-09-17 18:52:51 +0200 | [diff] [blame] | 36 | * |
| 37 | * Actually we want the ability to recognize our "sunxi" variant |
| 38 | * of the SPL. To do so, let's place a special signature into the |
| 39 | * "pub_head_size" field. We can reasonably expect Allwinner's |
| 40 | * boot0 to always have the upper 16 bits of this set to 0 (after |
| 41 | * all the value shouldn't be larger than the limit imposed by |
| 42 | * SRAM size). |
| 43 | * If the signature is present (at 0x14), then we know it's safe |
| 44 | * to use the remaining 8 bytes (at 0x18) for our own purposes. |
| 45 | * (E.g. sunxi-tools "fel" utility can pass information there.) |
Bernhard Nortmann | c9e8961 | 2015-09-17 18:52:50 +0200 | [diff] [blame] | 46 | */ |
Bernhard Nortmann | 01ad493 | 2015-09-17 18:52:51 +0200 | [diff] [blame] | 47 | union { |
| 48 | uint32_t pub_head_size; |
| 49 | uint8_t spl_signature[4]; |
| 50 | }; |
| 51 | uint32_t fel_script_address; |
Siarhei Siamashka | 08e978b | 2016-05-14 04:13:26 +0300 | [diff] [blame] | 52 | uint32_t reserved1[3]; |
| 53 | uint32_t boot_media; /* written here by the boot ROM */ |
| 54 | uint32_t reserved2[5]; /* padding, align to 64 bytes */ |
Bernhard Nortmann | c9e8961 | 2015-09-17 18:52:50 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
Bernhard Nortmann | ead498a | 2015-09-17 18:52:52 +0200 | [diff] [blame] | 57 | #define is_boot0_magic(addr) (memcmp((void *)addr, BOOT0_MAGIC, 8) == 0) |
| 58 | |
Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 59 | #endif |