ast2500-board.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2016 Google, Inc
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <ram.h>
  8. #include <timer.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/timer.h>
  11. #include <asm/arch/wdt.h>
  12. #include <linux/err.h>
  13. #include <dm/uclass.h>
  14. /*
  15. * Second Watchdog Timer by default is configured
  16. * to trigger secondary boot source.
  17. */
  18. #define AST_2ND_BOOT_WDT 1
  19. /*
  20. * Third Watchdog Timer by default is configured
  21. * to toggle Flash address mode switch before reset.
  22. */
  23. #define AST_FLASH_ADDR_DETECT_WDT 2
  24. DECLARE_GLOBAL_DATA_PTR;
  25. void lowlevel_init(void)
  26. {
  27. /*
  28. * These two watchdogs need to be stopped as soon as possible,
  29. * otherwise the board might hang. By default they are set to
  30. * a very short timeout and even simple debug write to serial
  31. * console early in the init process might cause them to fire.
  32. */
  33. struct ast_wdt *flash_addr_wdt =
  34. (struct ast_wdt *)(WDT_BASE +
  35. sizeof(struct ast_wdt) *
  36. AST_FLASH_ADDR_DETECT_WDT);
  37. clrbits_le32(&flash_addr_wdt->ctrl, WDT_CTRL_EN);
  38. #ifndef CONFIG_FIRMWARE_2ND_BOOT
  39. struct ast_wdt *sec_boot_wdt =
  40. (struct ast_wdt *)(WDT_BASE +
  41. sizeof(struct ast_wdt) *
  42. AST_2ND_BOOT_WDT);
  43. clrbits_le32(&sec_boot_wdt->ctrl, WDT_CTRL_EN);
  44. #endif
  45. }
  46. int board_init(void)
  47. {
  48. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  49. return 0;
  50. }
  51. int dram_init(void)
  52. {
  53. struct udevice *dev;
  54. struct ram_info ram;
  55. int ret;
  56. ret = uclass_get_device(UCLASS_RAM, 0, &dev);
  57. if (ret) {
  58. debug("DRAM FAIL1\r\n");
  59. return ret;
  60. }
  61. ret = ram_get_info(dev, &ram);
  62. if (ret) {
  63. debug("DRAM FAIL2\r\n");
  64. return ret;
  65. }
  66. gd->ram_size = ram.size;
  67. return 0;
  68. }