highbank.c 2.7 KB

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