Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 2 | /** |
| 3 | * (C) Copyright 2014, Cavium Inc. |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 4 | **/ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 9a3b4ce | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 7 | #include <cpu_func.h> |
Simon Glass | 9d92245 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 8 | #include <dm.h> |
Simon Glass | 2cf431c | 2019-11-14 12:57:47 -0700 | [diff] [blame] | 9 | #include <init.h> |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 10 | #include <malloc.h> |
| 11 | #include <errno.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 12 | #include <net.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 14 | #include <linux/compiler.h> |
| 15 | |
Sergey Temerkhanov | 3ed2ece | 2015-10-14 09:55:52 -0700 | [diff] [blame] | 16 | #include <cavium/atf.h> |
Alexander Graf | d473f0c | 2016-03-04 01:09:48 +0100 | [diff] [blame] | 17 | #include <asm/armv8/mmu.h> |
Sergey Temerkhanov | 3ed2ece | 2015-10-14 09:55:52 -0700 | [diff] [blame] | 18 | |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 19 | #if !CONFIG_IS_ENABLED(OF_CONTROL) |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 20 | #include <dm/platform_data/serial_pl01x.h> |
| 21 | |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 22 | static const struct pl01x_serial_plat serial0 = { |
Tom Rini | 65cc0e2 | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 23 | .base = CFG_SYS_SERIAL0, |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 24 | .type = TYPE_PL011, |
| 25 | .clock = 0, |
| 26 | .skip_init = true, |
| 27 | }; |
| 28 | |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 29 | U_BOOT_DRVINFO(thunderx_serial0) = { |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 30 | .name = "serial_pl01x", |
Simon Glass | caa4daa | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 31 | .plat = &serial0, |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 34 | static const struct pl01x_serial_plat serial1 = { |
Tom Rini | 65cc0e2 | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 35 | .base = CFG_SYS_SERIAL1, |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 36 | .type = TYPE_PL011, |
| 37 | .clock = 0, |
| 38 | .skip_init = true, |
| 39 | }; |
| 40 | |
Simon Glass | 20e442a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 41 | U_BOOT_DRVINFO(thunderx_serial1) = { |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 42 | .name = "serial_pl01x", |
Simon Glass | caa4daa | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 43 | .plat = &serial1, |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 44 | }; |
| 45 | #endif |
| 46 | |
| 47 | DECLARE_GLOBAL_DATA_PTR; |
| 48 | |
Alexander Graf | d473f0c | 2016-03-04 01:09:48 +0100 | [diff] [blame] | 49 | static struct mm_region thunderx_mem_map[] = { |
| 50 | { |
York Sun | cd4b0c5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 51 | .virt = 0x000000000000UL, |
| 52 | .phys = 0x000000000000UL, |
Alexander Graf | d473f0c | 2016-03-04 01:09:48 +0100 | [diff] [blame] | 53 | .size = 0x40000000000UL, |
| 54 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_NON_SHARE, |
| 55 | }, { |
York Sun | cd4b0c5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 56 | .virt = 0x800000000000UL, |
| 57 | .phys = 0x800000000000UL, |
Alexander Graf | d473f0c | 2016-03-04 01:09:48 +0100 | [diff] [blame] | 58 | .size = 0x40000000000UL, |
| 59 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 60 | PTE_BLOCK_NON_SHARE, |
| 61 | }, { |
York Sun | cd4b0c5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 62 | .virt = 0x840000000000UL, |
| 63 | .phys = 0x840000000000UL, |
Alexander Graf | d473f0c | 2016-03-04 01:09:48 +0100 | [diff] [blame] | 64 | .size = 0x40000000000UL, |
| 65 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 66 | PTE_BLOCK_NON_SHARE, |
| 67 | }, { |
| 68 | /* List terminator */ |
| 69 | 0, |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | struct mm_region *mem_map = thunderx_mem_map; |
| 74 | |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 75 | int board_init(void) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | int timer_init(void) |
| 81 | { |
| 82 | return 0; |
| 83 | } |
| 84 | |
Sergey Temerkhanov | 3ed2ece | 2015-10-14 09:55:52 -0700 | [diff] [blame] | 85 | int dram_init(void) |
| 86 | { |
| 87 | ssize_t node_count = atf_node_count(); |
| 88 | ssize_t dram_size; |
| 89 | int node; |
| 90 | |
| 91 | printf("Initializing\nNodes in system: %zd\n", node_count); |
| 92 | |
| 93 | gd->ram_size = 0; |
| 94 | |
| 95 | for (node = 0; node < node_count; node++) { |
| 96 | dram_size = atf_dram_size(node); |
| 97 | printf("Node %d: %zd MBytes of DRAM\n", node, dram_size >> 20); |
| 98 | gd->ram_size += dram_size; |
| 99 | } |
| 100 | |
| 101 | gd->ram_size -= MEM_BASE; |
| 102 | |
| 103 | *(unsigned long *)CPU_RELEASE_ADDR = 0; |
| 104 | |
| 105 | puts("DRAM size:"); |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 110 | /* |
| 111 | * Board specific reset that is system reset. |
| 112 | */ |
Harald Seiler | 35b65dd | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 113 | void reset_cpu(void) |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 114 | { |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | * Board specific ethernet initialization routine. |
| 119 | */ |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 120 | int board_eth_init(struct bd_info *bis) |
Sergey Temerkhanov | 746f985 | 2015-10-14 09:55:50 -0700 | [diff] [blame] | 121 | { |
| 122 | int rc = 0; |
| 123 | |
| 124 | return rc; |
| 125 | } |