1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2010-2011 Calxeda, Inc.
10 #include <fdt_support.h>
16 #include <linux/sizes.h>
19 #define HB_AHCI_BASE 0xffe08000
21 #define HB_SCU_A9_PWR_STATUS 0xfff10008
22 #define HB_SREG_A9_PWR_REQ 0xfff3cf00
23 #define HB_SREG_A9_BOOT_SRC_STAT 0xfff3cf04
24 #define HB_SREG_A9_PWRDOM_STAT 0xfff3cf20
25 #define HB_SREG_A15_PWR_CTRL 0xfff3c200
27 #define HB_PWR_SUSPEND 0
28 #define HB_PWR_SOFT_RESET 1
29 #define HB_PWR_HARD_RESET 2
30 #define HB_PWR_SHUTDOWN 3
32 #define PWRDOM_STAT_SATA 0x80000000
33 #define PWRDOM_STAT_PCI 0x40000000
34 #define PWRDOM_STAT_EMMC 0x20000000
36 #define HB_SCU_A9_PWR_NORMAL 0
37 #define HB_SCU_A9_PWR_DORMANT 2
38 #define HB_SCU_A9_PWR_OFF 3
40 DECLARE_GLOBAL_DATA_PTR;
42 void cphy_disable_overrides(void);
45 * Miscellaneous platform dependent initialisations
54 /* We know all the init functions have been run now */
55 int board_eth_init(bd_t *bis)
59 #ifdef CONFIG_CALXEDA_XGMAC
60 rc += calxedaxgmac_initialize(0, 0xfff50000);
61 rc += calxedaxgmac_initialize(1, 0xfff51000);
66 #ifdef CONFIG_SCSI_AHCI_PLAT
69 u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
71 cphy_disable_overrides();
72 if (reg & PWRDOM_STAT_SATA) {
73 ahci_init((void __iomem *)HB_AHCI_BASE);
79 #ifdef CONFIG_MISC_INIT_R
85 boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
86 sprintf(envbuffer, "bootcmd%d", boot_choice);
87 if (env_get(envbuffer)) {
88 sprintf(envbuffer, "run bootcmd%d", boot_choice);
89 env_set("bootcmd", envbuffer);
91 env_set("bootcmd", "");
99 gd->ram_size = SZ_512M;
103 #if defined(CONFIG_OF_BOARD_SETUP)
104 int ft_board_setup(void *fdt, bd_t *bd)
106 static const char disabled[] = "disabled";
107 u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
109 if (!(reg & PWRDOM_STAT_SATA))
110 do_fixup_by_compat(fdt, "calxeda,hb-ahci", "status",
111 disabled, sizeof(disabled), 1);
113 if (!(reg & PWRDOM_STAT_EMMC))
114 do_fixup_by_compat(fdt, "calxeda,hb-sdhci", "status",
115 disabled, sizeof(disabled), 1);
121 static int is_highbank(void)
125 asm volatile ("mrc p15, 0, %0, c0, c0, 0\n" : "=r"(midr));
127 return (midr & 0xfff0) == 0xc090;
130 void reset_cpu(ulong addr)
132 writel(HB_PWR_HARD_RESET, HB_SREG_A9_PWR_REQ);
134 writeb(HB_SCU_A9_PWR_OFF, HB_SCU_A9_PWR_STATUS);
136 writel(0x1, HB_SREG_A15_PWR_CTRL);
142 * turn off the override before transferring control to Linux, since Linux
143 * may not support spread spectrum.
145 void arch_preboot_os(void)
147 cphy_disable_overrides();