blob: 5f4c634362abef66b8fd293e8b046314934e77d6 [file] [log] [blame]
Steve Rae45f2c702016-06-02 15:10:56 -07001/*
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#include <usb.h>
16#include <usb/dwc2_udc.h>
17#include <g_dnl.h>
18
19#define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
20#define SECWATCHDOG_SDOGCR_EN_SHIFT 27
21#define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
22#define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
23#define SECWATCHDOG_SDOGCR_LD_SHIFT 0
24
25#ifndef CONFIG_USB_SERIALNO
26#define CONFIG_USB_SERIALNO "1234567890"
27#endif
28
29DECLARE_GLOBAL_DATA_PTR;
30
31/*
32 * board_init - early hardware init
33 */
34int board_init(void)
35{
36 printf("Relocation Offset is: %08lx\n", gd->reloc_off);
37
38 /* adress of boot parameters */
39 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
40
41 clk_init();
42
43 return 0;
44}
45
46/*
47 * misc_init_r - miscellaneous platform dependent initializations
48 */
49int misc_init_r(void)
50{
51 return 0;
52}
53
54/*
55 * dram_init - sets uboots idea of sdram size
56 */
57int dram_init(void)
58{
59 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
60 CONFIG_SYS_SDRAM_SIZE);
61 return 0;
62}
63
64/* This is called after dram_init() so use get_ram_size result */
Simon Glass2f949c32017-03-31 08:40:32 -060065int dram_init_banksize(void)
Steve Rae45f2c702016-06-02 15:10:56 -070066{
67 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
68 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060069
70 return 0;
Steve Rae45f2c702016-06-02 15:10:56 -070071}
72
Masahiro Yamada124f6ce2016-12-07 22:10:29 +090073#ifdef CONFIG_MMC_SDHCI_KONA
Steve Rae45f2c702016-06-02 15:10:56 -070074/*
75 * mmc_init - Initializes mmc
76 */
77int board_mmc_init(bd_t *bis)
78{
79 int ret = 0;
80
81 /* Register eMMC - SDIO2 */
82 ret = kona_sdhci_init(1, 400000, 0);
83 if (ret)
84 return ret;
85
86 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
87 ret = kona_sdhci_init(3, 400000, 0);
88 return ret;
89}
90#endif
91
92#ifdef CONFIG_USB_GADGET
93static struct dwc2_plat_otg_data bcm_otg_data = {
94 .regs_otg = HSOTG_BASE_ADDR
95};
96
97int board_usb_init(int index, enum usb_init_type init)
98{
99 debug("%s: performing dwc2_udc_probe\n", __func__);
100 return dwc2_udc_probe(&bcm_otg_data);
101}
102
103int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
104{
105 debug("%s\n", __func__);
106 if (!getenv("serial#"))
107 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
108 return 0;
109}
110
111int g_dnl_get_board_bcd_device_number(int gcnum)
112{
113 debug("%s\n", __func__);
114 return 1;
115}
116
117int board_usb_cleanup(int index, enum usb_init_type init)
118{
119 debug("%s\n", __func__);
120 return 0;
121}
122#endif