sunxi-common.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. /*
  2. * (C) Copyright 2012-2012 Henrik Nordstrom <henrik@henriknordstrom.net>
  3. *
  4. * (C) Copyright 2007-2011
  5. * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  6. * Tom Cubie <tangliang@allwinnertech.com>
  7. *
  8. * Configuration settings for the Allwinner sunxi series of boards.
  9. *
  10. * SPDX-License-Identifier: GPL-2.0+
  11. */
  12. #ifndef _SUNXI_COMMON_CONFIG_H
  13. #define _SUNXI_COMMON_CONFIG_H
  14. #include <linux/stringify.h>
  15. #ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
  16. /*
  17. * The U-Boot workarounds bugs in the outdated buggy sunxi-3.4 kernels at the
  18. * expense of restricting some features, so the regular machine id values can
  19. * be used.
  20. */
  21. # define CONFIG_MACH_TYPE_COMPAT_REV 0
  22. #else
  23. /*
  24. * A compatibility guard to prevent loading outdated buggy sunxi-3.4 kernels.
  25. * Only sunxi-3.4 kernels with appropriate fixes applied are able to pass
  26. * beyond the machine id check.
  27. */
  28. # define CONFIG_MACH_TYPE_COMPAT_REV 1
  29. #endif
  30. /*
  31. * High Level Configuration Options
  32. */
  33. #define CONFIG_SUNXI /* sunxi family */
  34. #ifdef CONFIG_SPL_BUILD
  35. #define CONFIG_SYS_THUMB_BUILD /* Thumbs mode to save space in SPL */
  36. #endif
  37. #include <asm/arch/cpu.h> /* get chip and board defs */
  38. #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DM_SERIAL)
  39. # define CONFIG_DW_SERIAL
  40. #endif
  41. /*
  42. * Display CPU information
  43. */
  44. #define CONFIG_DISPLAY_CPUINFO
  45. #define CONFIG_SYS_PROMPT "sunxi# "
  46. /* Serial & console */
  47. #define CONFIG_SYS_NS16550
  48. #define CONFIG_SYS_NS16550_SERIAL
  49. /* ns16550 reg in the low bits of cpu reg */
  50. #define CONFIG_SYS_NS16550_CLK 24000000
  51. #ifndef CONFIG_DM_SERIAL
  52. # define CONFIG_SYS_NS16550_REG_SIZE -4
  53. # define CONFIG_SYS_NS16550_COM1 SUNXI_UART0_BASE
  54. # define CONFIG_SYS_NS16550_COM2 SUNXI_UART1_BASE
  55. # define CONFIG_SYS_NS16550_COM3 SUNXI_UART2_BASE
  56. # define CONFIG_SYS_NS16550_COM4 SUNXI_UART3_BASE
  57. # define CONFIG_SYS_NS16550_COM5 SUNXI_R_UART_BASE
  58. #endif
  59. /* CPU */
  60. #define CONFIG_SYS_CACHELINE_SIZE 64
  61. /*
  62. * The DRAM Base differs between some models. We cannot use macros for the
  63. * CONFIG_FOO defines which contain the DRAM base address since they end
  64. * up unexpanded in include/autoconf.mk .
  65. *
  66. * So we have to have this #ifdef #else #endif block for these.
  67. */
  68. #ifdef CONFIG_MACH_SUN9I
  69. #define SDRAM_OFFSET(x) 0x2##x
  70. #define CONFIG_SYS_SDRAM_BASE 0x20000000
  71. #define CONFIG_SYS_LOAD_ADDR 0x22000000 /* default load address */
  72. #define CONFIG_SYS_TEXT_BASE 0x2a000000
  73. #define CONFIG_PRE_CON_BUF_ADDR 0x2f000000
  74. #define CONFIG_SYS_SPL_MALLOC_START 0x2ff00000
  75. #define CONFIG_SPL_BSS_START_ADDR 0x2ff80000
  76. #else
  77. #define SDRAM_OFFSET(x) 0x4##x
  78. #define CONFIG_SYS_SDRAM_BASE 0x40000000
  79. #define CONFIG_SYS_LOAD_ADDR 0x42000000 /* default load address */
  80. #define CONFIG_SYS_TEXT_BASE 0x4a000000
  81. #define CONFIG_PRE_CON_BUF_ADDR 0x4f000000
  82. #define CONFIG_SYS_SPL_MALLOC_START 0x4ff00000
  83. #define CONFIG_SPL_BSS_START_ADDR 0x4ff80000
  84. #endif
  85. #define CONFIG_SPL_BSS_MAX_SIZE 0x00080000 /* 512 KiB */
  86. #define CONFIG_SYS_SPL_MALLOC_SIZE 0x00080000 /* 512 KiB */
  87. #ifdef CONFIG_MACH_SUN9I
  88. /*
  89. * The A80's A1 sram starts at 0x00010000 rather then at 0x00000000 and is
  90. * slightly bigger. Note that it is possible to map the first 32 KiB of the
  91. * A1 at 0x00000000 like with older SoCs by writing 0x16aa0001 to the
  92. * undocumented 0x008000e0 SYS_CTRL register. Where the 16aa is a key and
  93. * the 1 actually activates the mapping of the first 32 KiB to 0x00000000.
  94. */
  95. #define CONFIG_SYS_INIT_RAM_ADDR 0x10000
  96. #define CONFIG_SYS_INIT_RAM_SIZE 0x0a000 /* 40 KiB */
  97. #else
  98. #define CONFIG_SYS_INIT_RAM_ADDR 0x0
  99. #define CONFIG_SYS_INIT_RAM_SIZE 0x8000 /* 32 KiB */
  100. #endif
  101. #define CONFIG_SYS_INIT_SP_OFFSET \
  102. (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
  103. #define CONFIG_SYS_INIT_SP_ADDR \
  104. (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
  105. #define CONFIG_NR_DRAM_BANKS 1
  106. #define PHYS_SDRAM_0 CONFIG_SYS_SDRAM_BASE
  107. #define PHYS_SDRAM_0_SIZE 0x80000000 /* 2 GiB */
  108. #ifdef CONFIG_AHCI
  109. #define CONFIG_LIBATA
  110. #define CONFIG_SCSI_AHCI
  111. #define CONFIG_SCSI_AHCI_PLAT
  112. #define CONFIG_SUNXI_AHCI
  113. #define CONFIG_SYS_64BIT_LBA
  114. #define CONFIG_SYS_SCSI_MAX_SCSI_ID 1
  115. #define CONFIG_SYS_SCSI_MAX_LUN 1
  116. #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
  117. CONFIG_SYS_SCSI_MAX_LUN)
  118. #define CONFIG_CMD_SCSI
  119. #endif
  120. #define CONFIG_CMD_MEMORY
  121. #define CONFIG_SETUP_MEMORY_TAGS
  122. #define CONFIG_CMDLINE_TAG
  123. #define CONFIG_INITRD_TAG
  124. #define CONFIG_SERIAL_TAG
  125. /* mmc config */
  126. #if !defined(CONFIG_UART0_PORT_F)
  127. #define CONFIG_MMC
  128. #define CONFIG_GENERIC_MMC
  129. #define CONFIG_CMD_MMC
  130. #define CONFIG_MMC_SUNXI
  131. #define CONFIG_MMC_SUNXI_SLOT 0
  132. #if !defined(CONFIG_SPL_NAND_SUPPORT)
  133. #define CONFIG_ENV_IS_IN_MMC
  134. #define CONFIG_SYS_MMC_ENV_DEV 0 /* first detected MMC controller */
  135. #endif /* CONFIG_SPL_NAND_SUPPORT */
  136. #endif
  137. /* 4MB of malloc() pool */
  138. #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (4 << 20))
  139. /*
  140. * Miscellaneous configurable options
  141. */
  142. #define CONFIG_CMD_ECHO
  143. #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
  144. #define CONFIG_SYS_PBSIZE 1024 /* Print Buffer Size */
  145. #define CONFIG_SYS_MAXARGS 16 /* max number of command args */
  146. #define CONFIG_SYS_GENERIC_BOARD
  147. /* Boot Argument Buffer Size */
  148. #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
  149. /* standalone support */
  150. #define CONFIG_STANDALONE_LOAD_ADDR CONFIG_SYS_LOAD_ADDR
  151. /* baudrate */
  152. #define CONFIG_BAUDRATE 115200
  153. /* The stack sizes are set up in start.S using the settings below */
  154. #define CONFIG_STACKSIZE (256 << 10) /* 256 KiB */
  155. /* FLASH and environment organization */
  156. #define CONFIG_SYS_NO_FLASH
  157. #define CONFIG_SYS_MONITOR_LEN (512 << 10) /* 512 KiB */
  158. #define CONFIG_IDENT_STRING " Allwinner Technology"
  159. #define CONFIG_ENV_OFFSET (544 << 10) /* (8 + 24 + 512) KiB */
  160. #define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */
  161. #include <config_cmd_default.h>
  162. #undef CONFIG_CMD_FPGA
  163. #define CONFIG_FAT_WRITE /* enable write access */
  164. #define CONFIG_SPL_FRAMEWORK
  165. #define CONFIG_SPL_LIBCOMMON_SUPPORT
  166. #define CONFIG_SPL_SERIAL_SUPPORT
  167. #define CONFIG_SPL_LIBGENERIC_SUPPORT
  168. #define CONFIG_SPL_BOARD_LOAD_IMAGE
  169. #define CONFIG_SPL_TEXT_BASE 0x20 /* sram start+header */
  170. #define CONFIG_SPL_MAX_SIZE 0x5fe0 /* 24KB on sun4i/sun7i */
  171. #define CONFIG_SPL_LIBDISK_SUPPORT
  172. #if !defined(CONFIG_UART0_PORT_F)
  173. #define CONFIG_SPL_MMC_SUPPORT
  174. #endif
  175. #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/sunxi/u-boot-spl.lds"
  176. #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 80 /* 40KiB */
  177. #define CONFIG_SPL_PAD_TO 32768 /* decimal for 'dd' */
  178. /* end of 32 KiB in sram */
  179. #define LOW_LEVEL_SRAM_STACK 0x00008000 /* End of sram */
  180. #define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK
  181. /* I2C */
  182. #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER
  183. #define CONFIG_SPL_I2C_SUPPORT
  184. #endif
  185. #if defined CONFIG_I2C0_ENABLE || defined CONFIG_I2C1_ENABLE || \
  186. defined CONFIG_I2C2_ENABLE || defined CONFIG_I2C3_ENABLE || \
  187. defined CONFIG_I2C4_ENABLE
  188. #define CONFIG_SYS_I2C
  189. #define CONFIG_SYS_I2C_MVTWSI
  190. #define CONFIG_SYS_I2C_SPEED 400000
  191. #define CONFIG_SYS_I2C_SLAVE 0x7f
  192. #define CONFIG_CMD_I2C
  193. #endif
  194. #if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
  195. #define CONFIG_SYS_I2C_SOFT
  196. #define CONFIG_SYS_I2C_SOFT_SPEED 50000
  197. #define CONFIG_SYS_I2C_SOFT_SLAVE 0x00
  198. /* We use pin names in Kconfig and sunxi_name_to_gpio() */
  199. #define CONFIG_SOFT_I2C_GPIO_SDA soft_i2c_gpio_sda
  200. #define CONFIG_SOFT_I2C_GPIO_SCL soft_i2c_gpio_scl
  201. #ifndef __ASSEMBLY__
  202. extern int soft_i2c_gpio_sda;
  203. extern int soft_i2c_gpio_scl;
  204. #endif
  205. #define CONFIG_VIDEO_LCD_I2C_BUS 0 /* The lcd panel soft i2c is bus 0 */
  206. #define CONFIG_SYS_SPD_BUS_NUM 1 /* And the axp209 i2c bus is bus 1 */
  207. #else
  208. #define CONFIG_SYS_SPD_BUS_NUM 0 /* The axp209 i2c bus is bus 0 */
  209. #define CONFIG_VIDEO_LCD_I2C_BUS -1 /* NA, but necessary to compile */
  210. #endif
  211. /* PMU */
  212. #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || defined CONFIG_AXP221_POWER
  213. #define CONFIG_SPL_POWER_SUPPORT
  214. #endif
  215. #ifndef CONFIG_CONS_INDEX
  216. #define CONFIG_CONS_INDEX 1 /* UART0 */
  217. #endif
  218. #if CONFIG_CONS_INDEX == 1
  219. #ifdef CONFIG_MACH_SUN9I
  220. #define OF_STDOUT_PATH "/soc/serial@07000000:115200"
  221. #else
  222. #define OF_STDOUT_PATH "/soc@01c00000/serial@01c28000:115200"
  223. #endif
  224. #elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUN5I)
  225. #define OF_STDOUT_PATH "/soc@01c00000/serial@01c28400:115200"
  226. #elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I)
  227. #define OF_STDOUT_PATH "/soc@01c00000/serial@01c28800:115200"
  228. #elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN8I)
  229. #define OF_STDOUT_PATH "/soc@01c00000/serial@01f02800:115200"
  230. #else
  231. #error Unsupported console port nr. Please fix stdout-path in sunxi-common.h.
  232. #endif
  233. /* GPIO */
  234. #define CONFIG_SUNXI_GPIO
  235. #define CONFIG_SPL_GPIO_SUPPORT
  236. #define CONFIG_CMD_GPIO
  237. #ifdef CONFIG_VIDEO
  238. /*
  239. * The amount of RAM to keep free at the top of RAM when relocating u-boot,
  240. * to use as framebuffer. This must be a multiple of 4096.
  241. */
  242. #define CONFIG_SUNXI_MAX_FB_SIZE (9 << 20)
  243. /* Do we want to initialize a simple FB? */
  244. #define CONFIG_VIDEO_DT_SIMPLEFB
  245. #define CONFIG_VIDEO_SUNXI
  246. #define CONFIG_CFB_CONSOLE
  247. #define CONFIG_VIDEO_SW_CURSOR
  248. #define CONFIG_VIDEO_LOGO
  249. #define CONFIG_VIDEO_STD_TIMINGS
  250. #define CONFIG_I2C_EDID
  251. /* allow both serial and cfb console. */
  252. #define CONFIG_CONSOLE_MUX
  253. /* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
  254. #define CONFIG_VGA_AS_SINGLE_DEVICE
  255. /* To be able to hook simplefb into dt */
  256. #ifdef CONFIG_VIDEO_DT_SIMPLEFB
  257. #define CONFIG_OF_BOARD_SETUP
  258. #endif
  259. #endif /* CONFIG_VIDEO */
  260. /* Ethernet support */
  261. #ifdef CONFIG_SUNXI_EMAC
  262. #define CONFIG_PHY_ADDR 1
  263. #define CONFIG_MII /* MII PHY management */
  264. #define CONFIG_PHYLIB
  265. #endif
  266. #ifdef CONFIG_SUNXI_GMAC
  267. #define CONFIG_DW_AUTONEG
  268. #define CONFIG_PHY_GIGE /* GMAC can use gigabit PHY */
  269. #define CONFIG_PHY_ADDR 1
  270. #define CONFIG_MII /* MII PHY management */
  271. #define CONFIG_PHYLIB
  272. #endif
  273. #ifdef CONFIG_USB_EHCI
  274. #define CONFIG_USB_OHCI_NEW
  275. #define CONFIG_USB_OHCI_SUNXI
  276. #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
  277. #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1
  278. #endif
  279. #ifdef CONFIG_USB_MUSB_SUNXI
  280. #define CONFIG_MUSB_HOST
  281. #define CONFIG_MUSB_PIO_ONLY
  282. #endif
  283. #if defined CONFIG_USB_EHCI || defined CONFIG_USB_MUSB_SUNXI
  284. #define CONFIG_CMD_USB
  285. #define CONFIG_USB_STORAGE
  286. #endif
  287. #ifdef CONFIG_USB_KEYBOARD
  288. #define CONFIG_CONSOLE_MUX
  289. #define CONFIG_PREBOOT
  290. #define CONFIG_SYS_STDIO_DEREGISTER
  291. #define CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
  292. #endif
  293. #if !defined CONFIG_ENV_IS_IN_MMC && \
  294. !defined CONFIG_ENV_IS_IN_NAND && \
  295. !defined CONFIG_ENV_IS_IN_FAT && \
  296. !defined CONFIG_ENV_IS_IN_SPI_FLASH
  297. #define CONFIG_ENV_IS_NOWHERE
  298. #endif
  299. #ifdef CONFIG_SPL_NAND_SUPPORT
  300. #define CONFIG_NAND
  301. #define CONFIG_SYS_NAND_SELF_INIT
  302. #define CONFIG_NAND_SUNXI
  303. #define CONFIG_CMD_SPL_WRITE_SIZE 0x000400
  304. #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x008000
  305. /* \todo Make these parameterisable in kernel config ? */
  306. #define CONFIG_NAND_SUNXI_PAGE_SIZE 8192
  307. #define CONFIG_NAND_SUNXI_ECC_STEP 1024
  308. #define CONFIG_NAND_SUNXI_ECC_STRENGTH 40
  309. #define CONFIG_NAND_SUNXI_ADDR_CYCLES 5
  310. #ifndef CONFIG_NAND_SUNXI_GPC_PORTS
  311. #error "No NAND GPC ports defined, NAND unsupported"
  312. #endif
  313. #endif /* CONFIG_SPL_NAND_SUPPORT */
  314. #define CONFIG_MISC_INIT_R
  315. #define CONFIG_SYS_CONSOLE_IS_IN_ENV
  316. #ifndef CONFIG_SPL_BUILD
  317. #include <config_distro_defaults.h>
  318. /* Enable pre-console buffer to get complete log on the VGA console */
  319. #define CONFIG_PRE_CONSOLE_BUFFER
  320. #define CONFIG_PRE_CON_BUF_SZ 4096 /* Aprox 2 80*25 screens */
  321. /*
  322. * 240M RAM (256M minimum minus space for the framebuffer),
  323. * 32M uncompressed kernel, 16M compressed kernel, 1M fdt,
  324. * 1M script, 1M pxe and the ramdisk at the end.
  325. */
  326. #define MEM_LAYOUT_ENV_SETTINGS \
  327. "bootm_size=0xf000000\0" \
  328. "kernel_addr_r=" __stringify(SDRAM_OFFSET(2000000)) "\0" \
  329. "fdt_addr_r=" __stringify(SDRAM_OFFSET(3000000)) "\0" \
  330. "scriptaddr=" __stringify(SDRAM_OFFSET(3100000)) "\0" \
  331. "pxefile_addr_r=" __stringify(SDRAM_OFFSET(3200000)) "\0" \
  332. "ramdisk_addr_r=" __stringify(SDRAM_OFFSET(3300000)) "\0"
  333. #ifdef CONFIG_MMC
  334. #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
  335. #else
  336. #define BOOT_TARGET_DEVICES_MMC(func)
  337. #endif
  338. #ifdef CONFIG_AHCI
  339. #define BOOT_TARGET_DEVICES_SCSI(func) func(SCSI, scsi, 0)
  340. #else
  341. #define BOOT_TARGET_DEVICES_SCSI(func)
  342. #endif
  343. #ifdef CONFIG_USB_EHCI
  344. #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
  345. #else
  346. #define BOOT_TARGET_DEVICES_USB(func)
  347. #endif
  348. #define BOOT_TARGET_DEVICES(func) \
  349. BOOT_TARGET_DEVICES_MMC(func) \
  350. BOOT_TARGET_DEVICES_SCSI(func) \
  351. BOOT_TARGET_DEVICES_USB(func) \
  352. func(PXE, pxe, na) \
  353. func(DHCP, dhcp, na)
  354. #include <config_distro_bootcmd.h>
  355. #ifdef CONFIG_USB_KEYBOARD
  356. #define CONSOLE_STDIN_SETTINGS \
  357. "preboot=usb start\0" \
  358. "stdin=serial,usbkbd\0"
  359. #else
  360. #define CONSOLE_STDIN_SETTINGS \
  361. "stdin=serial\0"
  362. #endif
  363. #ifdef CONFIG_VIDEO
  364. #define CONSOLE_STDOUT_SETTINGS \
  365. "stdout=serial,vga\0" \
  366. "stderr=serial,vga\0"
  367. #else
  368. #define CONSOLE_STDOUT_SETTINGS \
  369. "stdout=serial\0" \
  370. "stderr=serial\0"
  371. #endif
  372. #define CONSOLE_ENV_SETTINGS \
  373. CONSOLE_STDIN_SETTINGS \
  374. CONSOLE_STDOUT_SETTINGS
  375. #define CONFIG_EXTRA_ENV_SETTINGS \
  376. CONSOLE_ENV_SETTINGS \
  377. MEM_LAYOUT_ENV_SETTINGS \
  378. "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
  379. "console=ttyS0,115200\0" \
  380. BOOTENV
  381. #else /* ifndef CONFIG_SPL_BUILD */
  382. #define CONFIG_EXTRA_ENV_SETTINGS
  383. #endif
  384. #endif /* _SUNXI_COMMON_CONFIG_H */