Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 |
| 4 | * David Feng <fenghua@phytium.com.cn> |
| 5 | * Sharma Bhupesh <bhupesh.sharma@freescale.com> |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 6 | */ |
| 7 | #include <common.h> |
Simon Glass | 9a3b4ce | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Simon Glass | 9d92245 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 9 | #include <dm.h> |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 10 | #include <malloc.h> |
| 11 | #include <errno.h> |
| 12 | #include <netdev.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <linux/compiler.h> |
David Feng | d8bafe13 | 2015-01-31 11:55:29 +0800 | [diff] [blame] | 15 | #include <dm/platform_data/serial_pl01x.h> |
Liviu Dudau | 2fdc9b7 | 2015-10-19 11:08:32 +0100 | [diff] [blame] | 16 | #include "pcie.h" |
Alexander Graf | e593bf5 | 2016-03-04 01:09:51 +0100 | [diff] [blame] | 17 | #include <asm/armv8/mmu.h> |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
David Feng | d8bafe13 | 2015-01-31 11:55:29 +0800 | [diff] [blame] | 21 | static const struct pl01x_serial_platdata serial_platdata = { |
| 22 | .base = V2M_UART0, |
| 23 | .type = TYPE_PL011, |
Linus Walleij | d280ea0 | 2015-04-14 10:01:35 +0200 | [diff] [blame] | 24 | .clock = CONFIG_PL011_CLOCK, |
David Feng | d8bafe13 | 2015-01-31 11:55:29 +0800 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | U_BOOT_DEVICE(vexpress_serials) = { |
| 28 | .name = "serial_pl01x", |
| 29 | .platdata = &serial_platdata, |
| 30 | }; |
| 31 | |
Alexander Graf | e593bf5 | 2016-03-04 01:09:51 +0100 | [diff] [blame] | 32 | static struct mm_region vexpress64_mem_map[] = { |
| 33 | { |
York Sun | cd4b0c5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 34 | .virt = 0x0UL, |
| 35 | .phys = 0x0UL, |
Alexander Graf | e593bf5 | 2016-03-04 01:09:51 +0100 | [diff] [blame] | 36 | .size = 0x80000000UL, |
| 37 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 38 | PTE_BLOCK_NON_SHARE | |
| 39 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 40 | }, { |
York Sun | cd4b0c5 | 2016-06-24 16:46:22 -0700 | [diff] [blame] | 41 | .virt = 0x80000000UL, |
| 42 | .phys = 0x80000000UL, |
Alexander Graf | e593bf5 | 2016-03-04 01:09:51 +0100 | [diff] [blame] | 43 | .size = 0xff80000000UL, |
| 44 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 45 | PTE_BLOCK_INNER_SHARE |
| 46 | }, { |
| 47 | /* List terminator */ |
| 48 | 0, |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | struct mm_region *mem_map = vexpress64_mem_map; |
| 53 | |
Ryan Harkin | bc8d3bc | 2015-11-18 10:39:06 +0000 | [diff] [blame] | 54 | /* This function gets replaced by platforms supporting PCIe. |
| 55 | * The replacement function, eg. on Juno, initialises the PCIe bus. |
| 56 | */ |
| 57 | __weak void vexpress64_pcie_init(void) |
| 58 | { |
| 59 | } |
| 60 | |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 61 | int board_init(void) |
| 62 | { |
Liviu Dudau | 2fdc9b7 | 2015-10-19 11:08:32 +0100 | [diff] [blame] | 63 | vexpress64_pcie_init(); |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int dram_init(void) |
| 68 | { |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 69 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 70 | return 0; |
| 71 | } |
| 72 | |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 73 | int dram_init_banksize(void) |
Liviu Dudau | 2d0cee1 | 2015-10-19 11:08:31 +0100 | [diff] [blame] | 74 | { |
| 75 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 76 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
Ryan Harkin | 2c2b218 | 2015-11-18 10:39:07 +0000 | [diff] [blame] | 77 | #ifdef PHYS_SDRAM_2 |
Liviu Dudau | 2d0cee1 | 2015-10-19 11:08:31 +0100 | [diff] [blame] | 78 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 79 | gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; |
Ryan Harkin | 2c2b218 | 2015-11-18 10:39:07 +0000 | [diff] [blame] | 80 | #endif |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 81 | |
| 82 | return 0; |
Liviu Dudau | 2d0cee1 | 2015-10-19 11:08:31 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Andre Przywara | b3270e9 | 2020-04-27 19:18:01 +0100 | [diff] [blame^] | 85 | #ifdef CONFIG_OF_BOARD |
| 86 | #define JUNO_FLASH_SEC_SIZE (256 * 1024) |
| 87 | static phys_addr_t find_dtb_in_nor_flash(const char *partname) |
| 88 | { |
| 89 | phys_addr_t sector = CONFIG_SYS_FLASH_BASE; |
| 90 | int i; |
| 91 | |
| 92 | for (i = 0; |
| 93 | i < CONFIG_SYS_MAX_FLASH_SECT; |
| 94 | i++, sector += JUNO_FLASH_SEC_SIZE) { |
| 95 | int len = strlen(partname) + 1; |
| 96 | int offs; |
| 97 | phys_addr_t imginfo; |
| 98 | u32 reg; |
| 99 | |
| 100 | reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x04); |
| 101 | /* This makes up the string "HSLFTOOF" flash footer */ |
| 102 | if (reg != 0x464F4F54U) |
| 103 | continue; |
| 104 | reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x08); |
| 105 | if (reg != 0x464C5348U) |
| 106 | continue; |
| 107 | |
| 108 | for (offs = 0; offs < 32; offs += 4, len -= 4) { |
| 109 | reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x30 + offs); |
| 110 | if (strncmp(partname + offs, (char *)®, |
| 111 | len > 4 ? 4 : len)) |
| 112 | break; |
| 113 | |
| 114 | if (len > 4) |
| 115 | continue; |
| 116 | |
| 117 | reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x10); |
| 118 | imginfo = sector + JUNO_FLASH_SEC_SIZE - 0x30 - reg; |
| 119 | reg = readl(imginfo + 0x54); |
| 120 | |
| 121 | return CONFIG_SYS_FLASH_BASE + |
| 122 | reg * JUNO_FLASH_SEC_SIZE; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | printf("No DTB found\n"); |
| 127 | |
| 128 | return ~0; |
| 129 | } |
| 130 | |
| 131 | void *board_fdt_blob_setup(void) |
| 132 | { |
| 133 | phys_addr_t fdt_rom_addr = find_dtb_in_nor_flash(CONFIG_JUNO_DTB_PART); |
| 134 | |
| 135 | if (fdt_rom_addr == ~0UL) |
| 136 | return NULL; |
| 137 | |
| 138 | return (void *)fdt_rom_addr; |
| 139 | } |
| 140 | #endif |
| 141 | |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 142 | /* |
| 143 | * Board specific reset that is system reset. |
| 144 | */ |
| 145 | void reset_cpu(ulong addr) |
| 146 | { |
| 147 | } |
| 148 | |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 149 | /* |
| 150 | * Board specific ethernet initialization routine. |
| 151 | */ |
| 152 | int board_eth_init(bd_t *bis) |
| 153 | { |
| 154 | int rc = 0; |
| 155 | #ifdef CONFIG_SMC91111 |
| 156 | rc = smc91111_initialize(0, CONFIG_SMC91111_BASE); |
| 157 | #endif |
Linus Walleij | b31f9d7 | 2015-02-17 11:35:25 +0100 | [diff] [blame] | 158 | #ifdef CONFIG_SMC911X |
| 159 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 160 | #endif |
David Feng | 1291682 | 2013-12-14 11:47:37 +0800 | [diff] [blame] | 161 | return rc; |
| 162 | } |