blob: e3bf808d7e24f0eb61445dce634a161b439101fa [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Darwin Rambo8ab2c482014-02-11 11:06:38 -08002/*
3 * Copyright 2013 Broadcom Corporation.
Darwin Rambo8ab2c482014-02-11 11:06:38 -08004 */
5
6#include <common.h>
Simon Glass8e16b1e2019-12-28 10:45:05 -07007#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Darwin Rambo8ab2c482014-02-11 11:06:38 -08009#include <asm/io.h>
10#include <asm/mach-types.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -060011#include <env.h>
Darwin Rambo8ab2c482014-02-11 11:06:38 -080012#include <mmc.h>
13#include <asm/kona-common/kona_sdhci.h>
14#include <asm/kona-common/clk.h>
15#include <asm/arch/sysmap.h>
16
Jiandong Zheng3d310262015-07-09 14:26:40 -070017#include <usb.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010018#include <usb/dwc2_udc.h>
Jiandong Zheng3d310262015-07-09 14:26:40 -070019#include <g_dnl.h>
20
Darwin Rambo8ab2c482014-02-11 11:06:38 -080021#define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
22#define SECWATCHDOG_SDOGCR_EN_SHIFT 27
23#define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
24#define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
25#define SECWATCHDOG_SDOGCR_LD_SHIFT 0
26
Jiandong Zheng3d310262015-07-09 14:26:40 -070027#ifndef CONFIG_USB_SERIALNO
28#define CONFIG_USB_SERIALNO "1234567890"
29#endif
30
Darwin Rambo8ab2c482014-02-11 11:06:38 -080031DECLARE_GLOBAL_DATA_PTR;
32
33/*
34 * board_init - early hardware init
35 */
36int board_init(void)
37{
38 printf("Relocation Offset is: %08lx\n", gd->reloc_off);
39
40 /* adress of boot parameters */
41 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
42
43 clk_init();
44
45 return 0;
46}
47
48/*
49 * misc_init_r - miscellaneous platform dependent initializations
50 */
51int misc_init_r(void)
52{
53 /* Disable watchdog reset - watchdog unused */
54 writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
55 (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
56 (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
57 (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
58 (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
59
60 return 0;
61}
62
63/*
64 * dram_init - sets uboots idea of sdram size
65 */
66int dram_init(void)
67{
68 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
69 CONFIG_SYS_SDRAM_SIZE);
70 return 0;
71}
72
73/* This is called after dram_init() so use get_ram_size result */
Simon Glass2f949c32017-03-31 08:40:32 -060074int dram_init_banksize(void)
Darwin Rambo8ab2c482014-02-11 11:06:38 -080075{
76 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
77 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060078
79 return 0;
Darwin Rambo8ab2c482014-02-11 11:06:38 -080080}
81
Masahiro Yamada124f6ce2016-12-07 22:10:29 +090082#ifdef CONFIG_MMC_SDHCI_KONA
Darwin Rambo8ab2c482014-02-11 11:06:38 -080083/*
84 * mmc_init - Initializes mmc
85 */
86int board_mmc_init(bd_t *bis)
87{
88 int ret = 0;
89
90 /* Register eMMC - SDIO2 */
91 ret = kona_sdhci_init(1, 400000, 0);
92 if (ret)
93 return ret;
94
95 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
96 ret = kona_sdhci_init(3, 400000, 0);
97 return ret;
98}
99#endif
Jiandong Zheng3d310262015-07-09 14:26:40 -0700100
101#ifdef CONFIG_USB_GADGET
Marek Vasut6939aca2015-12-04 02:23:29 +0100102static struct dwc2_plat_otg_data bcm_otg_data = {
Jiandong Zheng3d310262015-07-09 14:26:40 -0700103 .regs_otg = HSOTG_BASE_ADDR
104};
105
106int board_usb_init(int index, enum usb_init_type init)
107{
Marek Vasut01b61fa2015-12-04 02:26:33 +0100108 debug("%s: performing dwc2_udc_probe\n", __func__);
109 return dwc2_udc_probe(&bcm_otg_data);
Jiandong Zheng3d310262015-07-09 14:26:40 -0700110}
111
112int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
113{
114 debug("%s\n", __func__);
Simon Glass64b723f2017-08-03 12:22:12 -0600115 if (!env_get("serial#"))
Jiandong Zheng3d310262015-07-09 14:26:40 -0700116 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
117 return 0;
118}
119
120int g_dnl_get_board_bcd_device_number(int gcnum)
121{
122 debug("%s\n", __func__);
123 return 1;
124}
125
126int board_usb_cleanup(int index, enum usb_init_type init)
127{
128 debug("%s\n", __func__);
129 return 0;
130}
131#endif