137fc0ed2SRob Herring /* 237fc0ed2SRob Herring * Copyright 2010-2011 Calxeda, Inc. 337fc0ed2SRob Herring * 4*1a459660SWolfgang 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 1237fc0ed2SRob Herring #include <asm/sizes.h> 13877012dfSRob Herring #include <asm/io.h> 1437fc0ed2SRob Herring 150c34e69fSRob Herring #define HB_SREG_A9_PWR_REQ 0xfff3cf00 164a3ea216SRob Herring #define HB_SREG_A9_BOOT_SRC_STAT 0xfff3cf04 170c34e69fSRob Herring #define HB_PWR_SUSPEND 0 180c34e69fSRob Herring #define HB_PWR_SOFT_RESET 1 190c34e69fSRob Herring #define HB_PWR_HARD_RESET 2 200c34e69fSRob Herring #define HB_PWR_SHUTDOWN 3 210c34e69fSRob Herring 2237fc0ed2SRob Herring DECLARE_GLOBAL_DATA_PTR; 2337fc0ed2SRob Herring 2437fc0ed2SRob Herring /* 2537fc0ed2SRob Herring * Miscellaneous platform dependent initialisations 2637fc0ed2SRob Herring */ 2737fc0ed2SRob Herring int board_init(void) 2837fc0ed2SRob Herring { 2937fc0ed2SRob Herring icache_enable(); 3037fc0ed2SRob Herring 3137fc0ed2SRob Herring return 0; 3237fc0ed2SRob Herring } 3337fc0ed2SRob Herring 349a420986SRob Herring /* We know all the init functions have been run now */ 359a420986SRob Herring int board_eth_init(bd_t *bis) 369a420986SRob Herring { 379a420986SRob Herring int rc = 0; 389a420986SRob Herring 399a420986SRob Herring #ifdef CONFIG_CALXEDA_XGMAC 409a420986SRob Herring rc += calxedaxgmac_initialize(0, 0xfff50000); 419a420986SRob Herring rc += calxedaxgmac_initialize(1, 0xfff51000); 429a420986SRob Herring #endif 439a420986SRob Herring return rc; 449a420986SRob Herring } 459a420986SRob Herring 4637fc0ed2SRob Herring int misc_init_r(void) 4737fc0ed2SRob Herring { 484a3ea216SRob Herring char envbuffer[16]; 494a3ea216SRob Herring u32 boot_choice; 504a3ea216SRob Herring 5137fc0ed2SRob Herring ahci_init(0xffe08000); 5237fc0ed2SRob Herring scsi_scan(1); 534a3ea216SRob Herring 544a3ea216SRob Herring boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff; 554a3ea216SRob Herring sprintf(envbuffer, "bootcmd%d", boot_choice); 564a3ea216SRob Herring if (getenv(envbuffer)) { 574a3ea216SRob Herring sprintf(envbuffer, "run bootcmd%d", boot_choice); 584a3ea216SRob Herring setenv("bootcmd", envbuffer); 594a3ea216SRob Herring } else 604a3ea216SRob Herring setenv("bootcmd", ""); 614a3ea216SRob Herring 6237fc0ed2SRob Herring return 0; 6337fc0ed2SRob Herring } 6437fc0ed2SRob Herring 6537fc0ed2SRob Herring int dram_init(void) 6637fc0ed2SRob Herring { 6737fc0ed2SRob Herring gd->ram_size = SZ_512M; 6837fc0ed2SRob Herring return 0; 6937fc0ed2SRob Herring } 7037fc0ed2SRob Herring 7137fc0ed2SRob Herring void dram_init_banksize(void) 7237fc0ed2SRob Herring { 7337fc0ed2SRob Herring gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; 7437fc0ed2SRob Herring gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; 7537fc0ed2SRob Herring } 7637fc0ed2SRob Herring 7737fc0ed2SRob Herring void reset_cpu(ulong addr) 7837fc0ed2SRob Herring { 790c34e69fSRob Herring writel(HB_PWR_HARD_RESET, HB_SREG_A9_PWR_REQ); 805bedf884SRob Herring 815bedf884SRob Herring wfi(); 8237fc0ed2SRob Herring } 83