vexpress64.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013
  4. * David Feng <fenghua@phytium.com.cn>
  5. * Sharma Bhupesh <bhupesh.sharma@freescale.com>
  6. */
  7. #include <common.h>
  8. #include <cpu_func.h>
  9. #include <dm.h>
  10. #include <init.h>
  11. #include <malloc.h>
  12. #include <errno.h>
  13. #include <net.h>
  14. #include <netdev.h>
  15. #include <asm/global_data.h>
  16. #include <asm/io.h>
  17. #include <linux/compiler.h>
  18. #include <dm/platform_data/serial_pl01x.h>
  19. #include "pcie.h"
  20. #include <asm/armv8/mmu.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. static const struct pl01x_serial_plat serial_plat = {
  23. .base = V2M_UART0,
  24. .type = TYPE_PL011,
  25. .clock = CONFIG_PL011_CLOCK,
  26. };
  27. U_BOOT_DRVINFO(vexpress_serials) = {
  28. .name = "serial_pl01x",
  29. .plat = &serial_plat,
  30. };
  31. static struct mm_region vexpress64_mem_map[] = {
  32. {
  33. .virt = 0x0UL,
  34. .phys = 0x0UL,
  35. .size = 0x80000000UL,
  36. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  37. PTE_BLOCK_NON_SHARE |
  38. PTE_BLOCK_PXN | PTE_BLOCK_UXN
  39. }, {
  40. .virt = 0x80000000UL,
  41. .phys = 0x80000000UL,
  42. .size = 0xff80000000UL,
  43. .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
  44. PTE_BLOCK_INNER_SHARE
  45. }, {
  46. /* List terminator */
  47. 0,
  48. }
  49. };
  50. struct mm_region *mem_map = vexpress64_mem_map;
  51. /* This function gets replaced by platforms supporting PCIe.
  52. * The replacement function, eg. on Juno, initialises the PCIe bus.
  53. */
  54. __weak void vexpress64_pcie_init(void)
  55. {
  56. }
  57. int board_init(void)
  58. {
  59. vexpress64_pcie_init();
  60. return 0;
  61. }
  62. int dram_init(void)
  63. {
  64. gd->ram_size = PHYS_SDRAM_1_SIZE;
  65. return 0;
  66. }
  67. int dram_init_banksize(void)
  68. {
  69. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  70. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  71. #ifdef PHYS_SDRAM_2
  72. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  73. gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
  74. #endif
  75. return 0;
  76. }
  77. #ifdef CONFIG_OF_BOARD
  78. #define JUNO_FLASH_SEC_SIZE (256 * 1024)
  79. static phys_addr_t find_dtb_in_nor_flash(const char *partname)
  80. {
  81. phys_addr_t sector = CONFIG_SYS_FLASH_BASE;
  82. int i;
  83. for (i = 0;
  84. i < CONFIG_SYS_MAX_FLASH_SECT;
  85. i++, sector += JUNO_FLASH_SEC_SIZE) {
  86. int len = strlen(partname) + 1;
  87. int offs;
  88. phys_addr_t imginfo;
  89. u32 reg;
  90. reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x04);
  91. /* This makes up the string "HSLFTOOF" flash footer */
  92. if (reg != 0x464F4F54U)
  93. continue;
  94. reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x08);
  95. if (reg != 0x464C5348U)
  96. continue;
  97. for (offs = 0; offs < 32; offs += 4, len -= 4) {
  98. reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x30 + offs);
  99. if (strncmp(partname + offs, (char *)&reg,
  100. len > 4 ? 4 : len))
  101. break;
  102. if (len > 4)
  103. continue;
  104. reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x10);
  105. imginfo = sector + JUNO_FLASH_SEC_SIZE - 0x30 - reg;
  106. reg = readl(imginfo + 0x54);
  107. return CONFIG_SYS_FLASH_BASE +
  108. reg * JUNO_FLASH_SEC_SIZE;
  109. }
  110. }
  111. printf("No DTB found\n");
  112. return ~0;
  113. }
  114. void *board_fdt_blob_setup(int *err)
  115. {
  116. phys_addr_t fdt_rom_addr = find_dtb_in_nor_flash(CONFIG_JUNO_DTB_PART);
  117. *err = 0;
  118. if (fdt_rom_addr == ~0UL) {
  119. *err = -ENXIO;
  120. return NULL;
  121. }
  122. return (void *)fdt_rom_addr;
  123. }
  124. #endif
  125. /* Actual reset is done via PSCI. */
  126. void reset_cpu(void)
  127. {
  128. }
  129. /*
  130. * Board specific ethernet initialization routine.
  131. */
  132. int board_eth_init(struct bd_info *bis)
  133. {
  134. int rc = 0;
  135. #ifndef CONFIG_DM_ETH
  136. #ifdef CONFIG_SMC91111
  137. rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
  138. #endif
  139. #ifdef CONFIG_SMC911X
  140. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  141. #endif
  142. #endif
  143. return rc;
  144. }