blob: 940a1c2c5066578571700243368ccbf604e090b7 [file] [log] [blame]
Darwin Rambo9ed679a2014-02-11 11:06:38 -08001/*
2 * Copyright 2013 Broadcom Corporation.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <asm/io.h>
9#include <asm/mach-types.h>
10#include <mmc.h>
11#include <asm/kona-common/kona_sdhci.h>
12#include <asm/kona-common/clk.h>
13#include <asm/arch/sysmap.h>
14
15#define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
16#define SECWATCHDOG_SDOGCR_EN_SHIFT 27
17#define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
18#define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
19#define SECWATCHDOG_SDOGCR_LD_SHIFT 0
20
21DECLARE_GLOBAL_DATA_PTR;
22
23/*
24 * board_init - early hardware init
25 */
26int board_init(void)
27{
28 printf("Relocation Offset is: %08lx\n", gd->reloc_off);
29
30 /* adress of boot parameters */
31 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
32
33 clk_init();
34
35 return 0;
36}
37
38/*
39 * misc_init_r - miscellaneous platform dependent initializations
40 */
41int misc_init_r(void)
42{
43 /* Disable watchdog reset - watchdog unused */
44 writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
45 (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
46 (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
47 (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
48 (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
49
50 return 0;
51}
52
53/*
54 * dram_init - sets uboots idea of sdram size
55 */
56int dram_init(void)
57{
58 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
59 CONFIG_SYS_SDRAM_SIZE);
60 return 0;
61}
62
63/* This is called after dram_init() so use get_ram_size result */
64void dram_init_banksize(void)
65{
66 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
67 gd->bd->bi_dram[0].size = gd->ram_size;
68}
69
70#ifdef CONFIG_KONA_SDHCI
71/*
72 * mmc_init - Initializes mmc
73 */
74int board_mmc_init(bd_t *bis)
75{
76 int ret = 0;
77
78 /* Register eMMC - SDIO2 */
79 ret = kona_sdhci_init(1, 400000, 0);
80 if (ret)
81 return ret;
82
83 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
84 ret = kona_sdhci_init(3, 400000, 0);
85 return ret;
86}
87#endif