rpi.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * (C) Copyright 2012-2016 Stephen Warren
  4. */
  5. #ifndef __CONFIG_H
  6. #define __CONFIG_H
  7. #include <linux/sizes.h>
  8. #include <asm/arch/timer.h>
  9. #ifndef __ASSEMBLY__
  10. #include <asm/arch/base.h>
  11. #endif
  12. #if defined(CONFIG_TARGET_RPI_2) || defined(CONFIG_TARGET_RPI_3_32B)
  13. #define CONFIG_SKIP_LOWLEVEL_INIT
  14. #endif
  15. /* Architecture, CPU, etc.*/
  16. /* Use SoC timer for AArch32, but architected timer for AArch64 */
  17. #ifndef CONFIG_ARM64
  18. #define CONFIG_SYS_TIMER_RATE 1000000
  19. #define CONFIG_SYS_TIMER_COUNTER \
  20. (&((struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR)->clo)
  21. #endif
  22. /*
  23. * 2835 is a SKU in a series for which the 2708 is the first or primary SoC,
  24. * so 2708 has historically been used rather than a dedicated 2835 ID.
  25. *
  26. * We don't define a machine type for bcm2709/bcm2836 since the RPi Foundation
  27. * chose to use someone else's previously registered machine ID (3139, MX51_GGC)
  28. * rather than obtaining a valid ID:-/
  29. *
  30. * For the bcm2837, hopefully a machine type is not needed, since everything
  31. * is DT.
  32. */
  33. #ifdef CONFIG_BCM2835
  34. #define CONFIG_MACH_TYPE MACH_TYPE_BCM2708
  35. #endif
  36. /* Memory layout */
  37. #define CONFIG_SYS_SDRAM_BASE 0x00000000
  38. #define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_TEXT_BASE
  39. /*
  40. * The board really has 256M. However, the VC (VideoCore co-processor) shares
  41. * the RAM, and uses a configurable portion at the top. We tell U-Boot that a
  42. * smaller amount of RAM is present in order to avoid stomping on the area
  43. * the VC uses.
  44. */
  45. #define CONFIG_SYS_SDRAM_SIZE SZ_128M
  46. #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \
  47. CONFIG_SYS_SDRAM_SIZE - \
  48. GENERATED_GBL_DATA_SIZE)
  49. #define CONFIG_SYS_MALLOC_LEN SZ_4M
  50. #define CONFIG_SYS_MEMTEST_START 0x00100000
  51. #define CONFIG_SYS_MEMTEST_END 0x00200000
  52. #define CONFIG_LOADADDR 0x00200000
  53. #ifdef CONFIG_ARM64
  54. #define CONFIG_SYS_BOOTM_LEN SZ_64M
  55. #endif
  56. /* Devices */
  57. /* GPIO */
  58. #define CONFIG_BCM2835_GPIO
  59. /* LCD */
  60. #define CONFIG_LCD_DT_SIMPLEFB
  61. #define CONFIG_VIDEO_BCM2835
  62. #ifdef CONFIG_CMD_USB
  63. #define CONFIG_TFTP_TSIZE
  64. #endif
  65. /* Console configuration */
  66. #define CONFIG_SYS_CBSIZE 1024
  67. /* Environment */
  68. #define CONFIG_SYS_LOAD_ADDR 0x1000000
  69. /* Shell */
  70. /* ATAGs support for bootm/bootz */
  71. #define CONFIG_SETUP_MEMORY_TAGS
  72. #define CONFIG_CMDLINE_TAG
  73. #define CONFIG_INITRD_TAG
  74. /* Environment */
  75. #define ENV_DEVICE_SETTINGS \
  76. "stdin=serial,usbkbd\0" \
  77. "stdout=serial,vidconsole\0" \
  78. "stderr=serial,vidconsole\0"
  79. #ifdef CONFIG_ARM64
  80. #define FDT_HIGH "ffffffffffffffff"
  81. #define INITRD_HIGH "ffffffffffffffff"
  82. #else
  83. #define FDT_HIGH "ffffffff"
  84. #define INITRD_HIGH "ffffffff"
  85. #endif
  86. /*
  87. * Memory layout for where various images get loaded by boot scripts:
  88. *
  89. * I suspect address 0 is used as the SMP pen on the RPi2, so avoid this.
  90. *
  91. * Older versions of the boot firmware place the firmware-loaded DTB at 0x100,
  92. * newer versions place it in high memory. So prevent U-Boot from doing its own
  93. * DTB + initrd relocation so that we won't accidentally relocate the initrd
  94. * over the firmware-loaded DTB and generally try to lay out things starting
  95. * from the bottom of RAM.
  96. *
  97. * kernel_addr_r has different constraints on ARM and Aarch64. For 32-bit ARM,
  98. * it must be within the first 128M of RAM in order for the kernel's
  99. * CONFIG_AUTO_ZRELADDR option to work. The kernel itself will be decompressed
  100. * to 0x8000 but the decompressor clobbers 0x4000-0x8000 as well. The
  101. * decompressor also likes to relocate itself to right past the end of the
  102. * decompressed kernel, so in total the sum of the compressed and and
  103. * decompressed kernel needs to be reserved.
  104. *
  105. * For Aarch64, the kernel image is uncompressed and must be loaded at
  106. * text_offset bytes (specified in the header of the Image) into a 2MB
  107. * boundary. The 'booti' command relocates the image if necessary. Linux uses
  108. * a default text_offset of 0x80000. In summary, loading at 0x80000
  109. * satisfies all these constraints and reserving memory up to 0x02400000
  110. * permits fairly large (roughly 36M) kernels.
  111. *
  112. * scriptaddr and pxefile_addr_r can be pretty much anywhere that doesn't
  113. * conflict with something else. Reserving 1M for each of them at
  114. * 0x02400000-0x02500000 and 0x02500000-0x02600000 should be plenty.
  115. *
  116. * On ARM, both the DTB and any possible initrd must be loaded such that they
  117. * fit inside the lowmem mapping in Linux. In practice, this usually means not
  118. * more than ~700M away from the start of the kernel image but this number can
  119. * be larger OR smaller depending on e.g. the 'vmalloc=xxxM' command line
  120. * parameter given to the kernel. So reserving memory from low to high
  121. * satisfies this constraint again. Reserving 1M at 0x02600000-0x02700000 for
  122. * the DTB leaves rest of the free RAM to the initrd starting at 0x02700000.
  123. * Even with the smallest possible CPU-GPU memory split of the CPU getting
  124. * only 64M, the remaining 25M starting at 0x02700000 should allow quite
  125. * large initrds before they start colliding with U-Boot.
  126. */
  127. #define ENV_MEM_LAYOUT_SETTINGS \
  128. "fdt_high=" FDT_HIGH "\0" \
  129. "initrd_high=" INITRD_HIGH "\0" \
  130. "kernel_addr_r=0x00080000\0" \
  131. "scriptaddr=0x02400000\0" \
  132. "pxefile_addr_r=0x02500000\0" \
  133. "fdt_addr_r=0x02600000\0" \
  134. "ramdisk_addr_r=0x02700000\0"
  135. #if CONFIG_IS_ENABLED(CMD_MMC)
  136. #define BOOT_TARGET_MMC(func) \
  137. func(MMC, mmc, 0) \
  138. func(MMC, mmc, 1)
  139. #else
  140. #define BOOT_TARGET_MMC(func)
  141. #endif
  142. #if CONFIG_IS_ENABLED(CMD_USB)
  143. #define BOOT_TARGET_USB(func) func(USB, usb, 0)
  144. #else
  145. #define BOOT_TARGET_USB(func)
  146. #endif
  147. #if CONFIG_IS_ENABLED(CMD_PXE)
  148. #define BOOT_TARGET_PXE(func) func(PXE, pxe, na)
  149. #else
  150. #define BOOT_TARGET_PXE(func)
  151. #endif
  152. #if CONFIG_IS_ENABLED(CMD_DHCP)
  153. #define BOOT_TARGET_DHCP(func) func(DHCP, dhcp, na)
  154. #else
  155. #define BOOT_TARGET_DHCP(func)
  156. #endif
  157. #define BOOT_TARGET_DEVICES(func) \
  158. BOOT_TARGET_MMC(func) \
  159. BOOT_TARGET_USB(func) \
  160. BOOT_TARGET_PXE(func) \
  161. BOOT_TARGET_DHCP(func)
  162. #include <config_distro_bootcmd.h>
  163. #define CONFIG_EXTRA_ENV_SETTINGS \
  164. "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
  165. ENV_DEVICE_SETTINGS \
  166. ENV_MEM_LAYOUT_SETTINGS \
  167. BOOTENV
  168. #endif