blob: 8cdcea8aaca54f548738bf7503245a6d51053c21 [file] [log] [blame]
Rob Herring73089ad2011-10-24 08:50:20 +00001/*
2 * Copyright 2010-2011 Calxeda, Inc.
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Rob Herring73089ad2011-10-24 08:50:20 +00005 */
6
7#include <common.h>
8#include <ahci.h>
Rob Herring12db8022012-02-21 12:52:26 +00009#include <netdev.h>
Rob Herring73089ad2011-10-24 08:50:20 +000010#include <scsi.h>
11
12#include <asm/sizes.h>
Rob Herring02fe7852012-02-01 16:57:54 +000013#include <asm/io.h>
Rob Herring73089ad2011-10-24 08:50:20 +000014
Rob Herringf9904ce2012-02-01 16:57:55 +000015#define HB_SREG_A9_PWR_REQ 0xfff3cf00
Rob Herring06d00742012-02-01 16:57:57 +000016#define HB_SREG_A9_BOOT_SRC_STAT 0xfff3cf04
Rob Herringf9904ce2012-02-01 16:57:55 +000017#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
Rob Herring73089ad2011-10-24 08:50:20 +000022DECLARE_GLOBAL_DATA_PTR;
23
24/*
25 * Miscellaneous platform dependent initialisations
26 */
27int board_init(void)
28{
29 icache_enable();
30
31 return 0;
32}
33
Rob Herring6fd09422011-12-15 11:15:50 +000034/* We know all the init functions have been run now */
35int board_eth_init(bd_t *bis)
36{
37 int rc = 0;
38
39#ifdef CONFIG_CALXEDA_XGMAC
40 rc += calxedaxgmac_initialize(0, 0xfff50000);
41 rc += calxedaxgmac_initialize(1, 0xfff51000);
42#endif
43 return rc;
44}
45
Rob Herring73089ad2011-10-24 08:50:20 +000046int misc_init_r(void)
47{
Rob Herring06d00742012-02-01 16:57:57 +000048 char envbuffer[16];
49 u32 boot_choice;
50
Rob Herring73089ad2011-10-24 08:50:20 +000051 ahci_init(0xffe08000);
52 scsi_scan(1);
Rob Herring06d00742012-02-01 16:57:57 +000053
54 boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
55 sprintf(envbuffer, "bootcmd%d", boot_choice);
56 if (getenv(envbuffer)) {
57 sprintf(envbuffer, "run bootcmd%d", boot_choice);
58 setenv("bootcmd", envbuffer);
59 } else
60 setenv("bootcmd", "");
61
Rob Herring73089ad2011-10-24 08:50:20 +000062 return 0;
63}
64
65int dram_init(void)
66{
67 gd->ram_size = SZ_512M;
68 return 0;
69}
70
71void dram_init_banksize(void)
72{
73 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
74 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
75}
76
77void reset_cpu(ulong addr)
78{
Rob Herringf9904ce2012-02-01 16:57:55 +000079 writel(HB_PWR_HARD_RESET, HB_SREG_A9_PWR_REQ);
Rob Herring35139602012-12-02 17:06:22 +000080
81 wfi();
Rob Herring73089ad2011-10-24 08:50:20 +000082}