xref: /openbmc/u-boot/board/highbank/highbank.c (revision 9efaca3e847696ed40fca1dbbc621fcc35b8d94c)
137fc0ed2SRob Herring /*
237fc0ed2SRob Herring  * Copyright 2010-2011 Calxeda, Inc.
337fc0ed2SRob Herring  *
41a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
537fc0ed2SRob Herring  */
637fc0ed2SRob Herring 
737fc0ed2SRob Herring #include <common.h>
837fc0ed2SRob Herring #include <ahci.h>
9bd0d90efSRob Herring #include <netdev.h>
1037fc0ed2SRob Herring #include <scsi.h>
1137fc0ed2SRob Herring 
121ace4022SAlexey Brodkin #include <linux/sizes.h>
13877012dfSRob Herring #include <asm/io.h>
1437fc0ed2SRob Herring 
1576c3999dSRob Herring #define HB_AHCI_BASE			0xffe08000
1676c3999dSRob Herring 
170c34e69fSRob Herring #define HB_SREG_A9_PWR_REQ		0xfff3cf00
184a3ea216SRob Herring #define HB_SREG_A9_BOOT_SRC_STAT	0xfff3cf04
1976c3999dSRob Herring #define HB_SREG_A9_PWRDOM_STAT		0xfff3cf20
2076c3999dSRob Herring 
210c34e69fSRob Herring #define HB_PWR_SUSPEND			0
220c34e69fSRob Herring #define HB_PWR_SOFT_RESET		1
230c34e69fSRob Herring #define HB_PWR_HARD_RESET		2
240c34e69fSRob Herring #define HB_PWR_SHUTDOWN			3
250c34e69fSRob Herring 
2676c3999dSRob Herring #define PWRDOM_STAT_SATA		0x80000000
2776c3999dSRob Herring #define PWRDOM_STAT_PCI			0x40000000
2876c3999dSRob Herring #define PWRDOM_STAT_EMMC		0x20000000
2976c3999dSRob Herring 
3037fc0ed2SRob Herring DECLARE_GLOBAL_DATA_PTR;
3137fc0ed2SRob Herring 
3237fc0ed2SRob Herring /*
3337fc0ed2SRob Herring  * Miscellaneous platform dependent initialisations
3437fc0ed2SRob Herring  */
3537fc0ed2SRob Herring int board_init(void)
3637fc0ed2SRob Herring {
3737fc0ed2SRob Herring 	icache_enable();
3837fc0ed2SRob Herring 
3937fc0ed2SRob Herring 	return 0;
4037fc0ed2SRob Herring }
4137fc0ed2SRob Herring 
429a420986SRob Herring /* We know all the init functions have been run now */
439a420986SRob Herring int board_eth_init(bd_t *bis)
449a420986SRob Herring {
459a420986SRob Herring 	int rc = 0;
469a420986SRob Herring 
479a420986SRob Herring #ifdef CONFIG_CALXEDA_XGMAC
489a420986SRob Herring 	rc += calxedaxgmac_initialize(0, 0xfff50000);
499a420986SRob Herring 	rc += calxedaxgmac_initialize(1, 0xfff51000);
509a420986SRob Herring #endif
519a420986SRob Herring 	return rc;
529a420986SRob Herring }
539a420986SRob Herring 
54b9463226SIan Campbell #ifdef CONFIG_SCSI_AHCI_PLAT
55b9463226SIan Campbell void scsi_init(void)
5637fc0ed2SRob Herring {
5776c3999dSRob Herring 	u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
584a3ea216SRob Herring 
5976c3999dSRob Herring 	if (reg & PWRDOM_STAT_SATA) {
60*9efaca3eSScott Wood 		ahci_init((void __iomem *)HB_AHCI_BASE);
6137fc0ed2SRob Herring 		scsi_scan(1);
6276c3999dSRob Herring 	}
63b9463226SIan Campbell }
64b9463226SIan Campbell #endif
65b9463226SIan Campbell 
66b9463226SIan Campbell #ifdef CONFIG_MISC_INIT_R
67b9463226SIan Campbell int misc_init_r(void)
68b9463226SIan Campbell {
69b9463226SIan Campbell 	char envbuffer[16];
70b9463226SIan Campbell 	u32 boot_choice;
714a3ea216SRob Herring 
724a3ea216SRob Herring 	boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
734a3ea216SRob Herring 	sprintf(envbuffer, "bootcmd%d", boot_choice);
744a3ea216SRob Herring 	if (getenv(envbuffer)) {
754a3ea216SRob Herring 		sprintf(envbuffer, "run bootcmd%d", boot_choice);
764a3ea216SRob Herring 		setenv("bootcmd", envbuffer);
774a3ea216SRob Herring 	} else
784a3ea216SRob Herring 		setenv("bootcmd", "");
794a3ea216SRob Herring 
8037fc0ed2SRob Herring 	return 0;
8137fc0ed2SRob Herring }
8295395023SRob Herring #endif
8337fc0ed2SRob Herring 
8437fc0ed2SRob Herring int dram_init(void)
8537fc0ed2SRob Herring {
8637fc0ed2SRob Herring 	gd->ram_size = SZ_512M;
8737fc0ed2SRob Herring 	return 0;
8837fc0ed2SRob Herring }
8937fc0ed2SRob Herring 
9037fc0ed2SRob Herring void dram_init_banksize(void)
9137fc0ed2SRob Herring {
9237fc0ed2SRob Herring 	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
9337fc0ed2SRob Herring 	gd->bd->bi_dram[0].size =  PHYS_SDRAM_1_SIZE;
9437fc0ed2SRob Herring }
9537fc0ed2SRob Herring 
9676c3999dSRob Herring #if defined(CONFIG_OF_BOARD_SETUP)
97e895a4b0SSimon Glass int ft_board_setup(void *fdt, bd_t *bd)
9876c3999dSRob Herring {
9976c3999dSRob Herring 	static const char disabled[] = "disabled";
10076c3999dSRob Herring 	u32 reg = readl(HB_SREG_A9_PWRDOM_STAT);
10176c3999dSRob Herring 
10276c3999dSRob Herring 	if (!(reg & PWRDOM_STAT_SATA))
10376c3999dSRob Herring 		do_fixup_by_compat(fdt, "calxeda,hb-ahci", "status",
10476c3999dSRob Herring 			disabled, sizeof(disabled), 1);
10576c3999dSRob Herring 
10676c3999dSRob Herring 	if (!(reg & PWRDOM_STAT_EMMC))
10776c3999dSRob Herring 		do_fixup_by_compat(fdt, "calxeda,hb-sdhci", "status",
10876c3999dSRob Herring 			disabled, sizeof(disabled), 1);
109e895a4b0SSimon Glass 
110e895a4b0SSimon Glass 	return 0;
11176c3999dSRob Herring }
11276c3999dSRob Herring #endif
11376c3999dSRob Herring 
11437fc0ed2SRob Herring void reset_cpu(ulong addr)
11537fc0ed2SRob Herring {
1160c34e69fSRob Herring 	writel(HB_PWR_HARD_RESET, HB_SREG_A9_PWR_REQ);
1175bedf884SRob Herring 
1185bedf884SRob Herring 	wfi();
11937fc0ed2SRob Herring }
120