Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010-2011 Calxeda, Inc. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <ahci.h> |
Rob Herring | 12db802 | 2012-02-21 12:52:26 +0000 | [diff] [blame] | 9 | #include <netdev.h> |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 10 | #include <scsi.h> |
| 11 | |
| 12 | #include <asm/sizes.h> |
Rob Herring | 02fe785 | 2012-02-01 16:57:54 +0000 | [diff] [blame] | 13 | #include <asm/io.h> |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 14 | |
Rob Herring | f9904ce | 2012-02-01 16:57:55 +0000 | [diff] [blame] | 15 | #define HB_SREG_A9_PWR_REQ 0xfff3cf00 |
Rob Herring | 06d0074 | 2012-02-01 16:57:57 +0000 | [diff] [blame] | 16 | #define HB_SREG_A9_BOOT_SRC_STAT 0xfff3cf04 |
Rob Herring | f9904ce | 2012-02-01 16:57:55 +0000 | [diff] [blame] | 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 | |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
| 24 | /* |
| 25 | * Miscellaneous platform dependent initialisations |
| 26 | */ |
| 27 | int board_init(void) |
| 28 | { |
| 29 | icache_enable(); |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | |
Rob Herring | 6fd0942 | 2011-12-15 11:15:50 +0000 | [diff] [blame] | 34 | /* We know all the init functions have been run now */ |
| 35 | int 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 Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 46 | int misc_init_r(void) |
| 47 | { |
Rob Herring | 06d0074 | 2012-02-01 16:57:57 +0000 | [diff] [blame] | 48 | char envbuffer[16]; |
| 49 | u32 boot_choice; |
| 50 | |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 51 | ahci_init(0xffe08000); |
| 52 | scsi_scan(1); |
Rob Herring | 06d0074 | 2012-02-01 16:57:57 +0000 | [diff] [blame] | 53 | |
| 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 Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | int dram_init(void) |
| 66 | { |
| 67 | gd->ram_size = SZ_512M; |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | void 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 | |
| 77 | void reset_cpu(ulong addr) |
| 78 | { |
Rob Herring | f9904ce | 2012-02-01 16:57:55 +0000 | [diff] [blame] | 79 | writel(HB_PWR_HARD_RESET, HB_SREG_A9_PWR_REQ); |
Rob Herring | 3513960 | 2012-12-02 17:06:22 +0000 | [diff] [blame] | 80 | |
| 81 | wfi(); |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 82 | } |