highbank.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2010-2011 Calxeda, Inc.
  4. */
  5. #include <common.h>
  6. #include <ahci.h>
  7. #include <env.h>
  8. #include <netdev.h>
  9. #include <scsi.h>
  10. #include <linux/sizes.h>
  11. #include <asm/io.h>
  12. #define HB_AHCI_BASE 0xffe08000
  13. #define HB_SCU_A9_PWR_STATUS 0xfff10008
  14. #define HB_SREG_A9_PWR_REQ 0xfff3cf00
  15. #define HB_SREG_A9_BOOT_SRC_STAT 0xfff3cf04
  16. #define HB_SREG_A9_PWRDOM_STAT 0xfff3cf20
  17. #define HB_SREG_A15_PWR_CTRL 0xfff3c200
  18. #define HB_PWR_SUSPEND 0
  19. #define HB_PWR_SOFT_RESET 1
  20. #define HB_PWR_HARD_RESET 2
  21. #define HB_PWR_SHUTDOWN 3
  22. #define PWRDOM_STAT_SATA 0x80000000
  23. #define PWRDOM_STAT_PCI 0x40000000
  24. #define PWRDOM_STAT_EMMC 0x20000000
  25. #define HB_SCU_A9_PWR_NORMAL 0
  26. #define HB_SCU_A9_PWR_DORMANT 2
  27. #define HB_SCU_A9_PWR_OFF 3
  28. DECLARE_GLOBAL_DATA_PTR;
  29. void cphy_disable_overrides(void);
  30. /*
  31. * Miscellaneous platform dependent initialisations
  32. */
  33. int board_init(void)
  34. {
  35. icache_enable();
  36. return 0;
  37. }
  38. /* We know all the init functions have been run now */
  39. int board_eth_init(bd_t *bis)
  40. {
  41. int rc = 0;
  42. #ifdef CONFIG_CALXEDA_XGMAC
  43. rc += calxedaxgmac_initialize(0, 0xfff50000);
  44. rc += calxedaxgmac_initialize(1, 0xfff51000);
  45. #endif
  46. return rc;
  47. }
  48. #ifdef CONFIG_SCSI_AHCI_PLAT
  49. void scsi_init(void)
  50. {
  51. u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
  52. cphy_disable_overrides();
  53. if (reg & PWRDOM_STAT_SATA) {
  54. ahci_init((void __iomem *)HB_AHCI_BASE);
  55. scsi_scan(true);
  56. }
  57. }
  58. #endif
  59. #ifdef CONFIG_MISC_INIT_R
  60. int misc_init_r(void)
  61. {
  62. char envbuffer[16];
  63. u32 boot_choice;
  64. boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
  65. sprintf(envbuffer, "bootcmd%d", boot_choice);
  66. if (env_get(envbuffer)) {
  67. sprintf(envbuffer, "run bootcmd%d", boot_choice);
  68. env_set("bootcmd", envbuffer);
  69. } else
  70. env_set("bootcmd", "");
  71. return 0;
  72. }
  73. #endif
  74. int dram_init(void)
  75. {
  76. gd->ram_size = SZ_512M;
  77. return 0;
  78. }
  79. #if defined(CONFIG_OF_BOARD_SETUP)
  80. int ft_board_setup(void *fdt, bd_t *bd)
  81. {
  82. static const char disabled[] = "disabled";
  83. u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
  84. if (!(reg & PWRDOM_STAT_SATA))
  85. do_fixup_by_compat(fdt, "calxeda,hb-ahci", "status",
  86. disabled, sizeof(disabled), 1);
  87. if (!(reg & PWRDOM_STAT_EMMC))
  88. do_fixup_by_compat(fdt, "calxeda,hb-sdhci", "status",
  89. disabled, sizeof(disabled), 1);
  90. return 0;
  91. }
  92. #endif
  93. static int is_highbank(void)
  94. {
  95. uint32_t midr;
  96. asm volatile ("mrc p15, 0, %0, c0, c0, 0\n" : "=r"(midr));
  97. return (midr & 0xfff0) == 0xc090;
  98. }
  99. void reset_cpu(ulong addr)
  100. {
  101. writel(HB_PWR_HARD_RESET, HB_SREG_A9_PWR_REQ);
  102. if (is_highbank())
  103. writeb(HB_SCU_A9_PWR_OFF, HB_SCU_A9_PWR_STATUS);
  104. else
  105. writel(0x1, HB_SREG_A15_PWR_CTRL);
  106. wfi();
  107. }
  108. /*
  109. * turn off the override before transferring control to Linux, since Linux
  110. * may not support spread spectrum.
  111. */
  112. void arch_preboot_os(void)
  113. {
  114. cphy_disable_overrides();
  115. }