blob: 9d294903e9686e78baa0e519dbf8f9a3ff6c90db [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
David Feng3b5458c2013-12-14 11:47:37 +08002/*
3 * (C) Copyright 2013
4 * David Feng <fenghua@phytium.com.cn>
5 * Sharma Bhupesh <bhupesh.sharma@freescale.com>
David Feng3b5458c2013-12-14 11:47:37 +08006 */
7#include <common.h>
Simon Glassafb02152019-12-28 10:45:01 -07008#include <cpu_func.h>
Simon Glass11c89f32017-05-17 17:18:03 -06009#include <dm.h>
Simon Glass97589732020-05-10 11:40:02 -060010#include <init.h>
David Feng3b5458c2013-12-14 11:47:37 +080011#include <malloc.h>
12#include <errno.h>
Simon Glass274e0b02020-05-10 11:39:56 -060013#include <net.h>
David Feng3b5458c2013-12-14 11:47:37 +080014#include <netdev.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
David Feng3b5458c2013-12-14 11:47:37 +080016#include <asm/io.h>
17#include <linux/compiler.h>
David Fengab33c2c2015-01-31 11:55:29 +080018#include <dm/platform_data/serial_pl01x.h>
Liviu Dudau8d1fdc32015-10-19 11:08:32 +010019#include "pcie.h"
Alexander Graf5889e392016-03-04 01:09:51 +010020#include <asm/armv8/mmu.h>
David Feng3b5458c2013-12-14 11:47:37 +080021
22DECLARE_GLOBAL_DATA_PTR;
23
Simon Glassb75b15b2020-12-03 16:55:23 -070024static const struct pl01x_serial_plat serial_plat = {
David Fengab33c2c2015-01-31 11:55:29 +080025 .base = V2M_UART0,
26 .type = TYPE_PL011,
Linus Walleij31e476e2015-04-14 10:01:35 +020027 .clock = CONFIG_PL011_CLOCK,
David Fengab33c2c2015-01-31 11:55:29 +080028};
29
Simon Glass1d8364a2020-12-28 20:34:54 -070030U_BOOT_DRVINFO(vexpress_serials) = {
David Fengab33c2c2015-01-31 11:55:29 +080031 .name = "serial_pl01x",
Simon Glassb75b15b2020-12-03 16:55:23 -070032 .plat = &serial_plat,
David Fengab33c2c2015-01-31 11:55:29 +080033};
34
Alexander Graf5889e392016-03-04 01:09:51 +010035static struct mm_region vexpress64_mem_map[] = {
36 {
York Sunc7104e52016-06-24 16:46:22 -070037 .virt = 0x0UL,
38 .phys = 0x0UL,
Alexander Graf5889e392016-03-04 01:09:51 +010039 .size = 0x80000000UL,
40 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
41 PTE_BLOCK_NON_SHARE |
42 PTE_BLOCK_PXN | PTE_BLOCK_UXN
43 }, {
York Sunc7104e52016-06-24 16:46:22 -070044 .virt = 0x80000000UL,
45 .phys = 0x80000000UL,
Alexander Graf5889e392016-03-04 01:09:51 +010046 .size = 0xff80000000UL,
47 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
48 PTE_BLOCK_INNER_SHARE
49 }, {
50 /* List terminator */
51 0,
52 }
53};
54
55struct mm_region *mem_map = vexpress64_mem_map;
56
Ryan Harkin8961d502015-11-18 10:39:06 +000057/* This function gets replaced by platforms supporting PCIe.
58 * The replacement function, eg. on Juno, initialises the PCIe bus.
59 */
60__weak void vexpress64_pcie_init(void)
61{
62}
63
David Feng3b5458c2013-12-14 11:47:37 +080064int board_init(void)
65{
Liviu Dudau8d1fdc32015-10-19 11:08:32 +010066 vexpress64_pcie_init();
David Feng3b5458c2013-12-14 11:47:37 +080067 return 0;
68}
69
70int dram_init(void)
71{
David Feng3b5458c2013-12-14 11:47:37 +080072 gd->ram_size = PHYS_SDRAM_1_SIZE;
73 return 0;
74}
75
Simon Glass2f949c32017-03-31 08:40:32 -060076int dram_init_banksize(void)
Liviu Dudau086c9772015-10-19 11:08:31 +010077{
78 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
79 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Ryan Harkin98d2fff2015-11-18 10:39:07 +000080#ifdef PHYS_SDRAM_2
Liviu Dudau086c9772015-10-19 11:08:31 +010081 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
82 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
Ryan Harkin98d2fff2015-11-18 10:39:07 +000083#endif
Simon Glass2f949c32017-03-31 08:40:32 -060084
85 return 0;
Liviu Dudau086c9772015-10-19 11:08:31 +010086}
87
Andre Przywara94504f42020-04-27 19:18:01 +010088#ifdef CONFIG_OF_BOARD
89#define JUNO_FLASH_SEC_SIZE (256 * 1024)
90static phys_addr_t find_dtb_in_nor_flash(const char *partname)
91{
92 phys_addr_t sector = CONFIG_SYS_FLASH_BASE;
93 int i;
94
95 for (i = 0;
96 i < CONFIG_SYS_MAX_FLASH_SECT;
97 i++, sector += JUNO_FLASH_SEC_SIZE) {
98 int len = strlen(partname) + 1;
99 int offs;
100 phys_addr_t imginfo;
101 u32 reg;
102
103 reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x04);
104 /* This makes up the string "HSLFTOOF" flash footer */
105 if (reg != 0x464F4F54U)
106 continue;
107 reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x08);
108 if (reg != 0x464C5348U)
109 continue;
110
111 for (offs = 0; offs < 32; offs += 4, len -= 4) {
112 reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x30 + offs);
113 if (strncmp(partname + offs, (char *)&reg,
114 len > 4 ? 4 : len))
115 break;
116
117 if (len > 4)
118 continue;
119
120 reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x10);
121 imginfo = sector + JUNO_FLASH_SEC_SIZE - 0x30 - reg;
122 reg = readl(imginfo + 0x54);
123
124 return CONFIG_SYS_FLASH_BASE +
125 reg * JUNO_FLASH_SEC_SIZE;
126 }
127 }
128
129 printf("No DTB found\n");
130
131 return ~0;
132}
133
134void *board_fdt_blob_setup(void)
135{
136 phys_addr_t fdt_rom_addr = find_dtb_in_nor_flash(CONFIG_JUNO_DTB_PART);
137
138 if (fdt_rom_addr == ~0UL)
139 return NULL;
140
141 return (void *)fdt_rom_addr;
142}
143#endif
144
Andre Przywara651c91b2020-04-27 19:18:02 +0100145/* Actual reset is done via PSCI. */
David Feng3b5458c2013-12-14 11:47:37 +0800146void reset_cpu(ulong addr)
147{
Darwin Rambod32d4112014-06-09 11:12:59 -0700148}
149
David Feng3b5458c2013-12-14 11:47:37 +0800150/*
151 * Board specific ethernet initialization routine.
152 */
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900153int board_eth_init(struct bd_info *bis)
David Feng3b5458c2013-12-14 11:47:37 +0800154{
155 int rc = 0;
Andre Przywarad263e762020-06-11 12:03:18 +0100156#ifndef CONFIG_DM_ETH
David Feng3b5458c2013-12-14 11:47:37 +0800157#ifdef CONFIG_SMC91111
158 rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
159#endif
Linus Walleij48b47552015-02-17 11:35:25 +0100160#ifdef CONFIG_SMC911X
161 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
162#endif
Andre Przywarad263e762020-06-11 12:03:18 +0100163#endif
David Feng3b5458c2013-12-14 11:47:37 +0800164 return rc;
165}