1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2013 Broadcom Corporation.
4 */
5
6 #include <common.h>
7 #include <init.h>
8 #include <log.h>
9 #include <asm/global_data.h>
10 #include <asm/io.h>
11 #include <asm/mach-types.h>
12 #include <env.h>
13 #include <mmc.h>
14 #include <asm/kona-common/kona_sdhci.h>
15 #include <asm/kona-common/clk.h>
16 #include <asm/arch/sysmap.h>
17
18 #include <usb.h>
19 #include <usb/dwc2_udc.h>
20 #include <g_dnl.h>
21
22 #define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
23 #define SECWATCHDOG_SDOGCR_EN_SHIFT 27
24 #define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
25 #define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
26 #define SECWATCHDOG_SDOGCR_LD_SHIFT 0
27
28 #ifndef CONFIG_USB_SERIALNO
29 #define CONFIG_USB_SERIALNO "1234567890"
30 #endif
31
32 DECLARE_GLOBAL_DATA_PTR;
33
34 /*
35 * board_init - early hardware init
36 */
board_init(void)37 int board_init(void)
38 {
39 printf("Relocation Offset is: %08lx\n", gd->reloc_off);
40
41 /* adress of boot parameters */
42 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
43
44 clk_init();
45
46 return 0;
47 }
48
49 /*
50 * misc_init_r - miscellaneous platform dependent initializations
51 */
misc_init_r(void)52 int misc_init_r(void)
53 {
54 return 0;
55 }
56
57 /*
58 * dram_init - sets uboots idea of sdram size
59 */
dram_init(void)60 int dram_init(void)
61 {
62 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
63 CONFIG_SYS_SDRAM_SIZE);
64 return 0;
65 }
66
67 /* This is called after dram_init() so use get_ram_size result */
dram_init_banksize(void)68 int dram_init_banksize(void)
69 {
70 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
71 gd->bd->bi_dram[0].size = gd->ram_size;
72
73 return 0;
74 }
75
76 #ifdef CONFIG_MMC_SDHCI_KONA
77 /*
78 * mmc_init - Initializes mmc
79 */
board_mmc_init(struct bd_info * bis)80 int board_mmc_init(struct bd_info *bis)
81 {
82 int ret = 0;
83
84 /* Register eMMC - SDIO2 */
85 ret = kona_sdhci_init(1, 400000, 0);
86 if (ret)
87 return ret;
88
89 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
90 ret = kona_sdhci_init(3, 400000, 0);
91 return ret;
92 }
93 #endif
94
95 #ifdef CONFIG_USB_GADGET
96 static struct dwc2_plat_otg_data bcm_otg_data = {
97 .regs_otg = HSOTG_BASE_ADDR
98 };
99
board_usb_init(int index,enum usb_init_type init)100 int board_usb_init(int index, enum usb_init_type init)
101 {
102 debug("%s: performing dwc2_udc_probe\n", __func__);
103 return dwc2_udc_probe(&bcm_otg_data);
104 }
105
g_dnl_bind_fixup(struct usb_device_descriptor * dev,const char * name)106 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
107 {
108 debug("%s\n", __func__);
109 if (!env_get("serial#"))
110 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
111 return 0;
112 }
113
g_dnl_get_board_bcd_device_number(int gcnum)114 int g_dnl_get_board_bcd_device_number(int gcnum)
115 {
116 debug("%s\n", __func__);
117 return 1;
118 }
119
board_usb_cleanup(int index,enum usb_init_type init)120 int board_usb_cleanup(int index, enum usb_init_type init)
121 {
122 debug("%s\n", __func__);
123 return 0;
124 }
125 #endif
126