blob: 40ced1a87ce4aa3f1cb4b00cc10a9404ad386a1d [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>
Darwin Rambo8ab2c482014-02-11 11:06:38 -08008#include <asm/io.h>
9#include <asm/mach-types.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -060010#include <env.h>
Darwin Rambo8ab2c482014-02-11 11:06:38 -080011#include <mmc.h>
12#include <asm/kona-common/kona_sdhci.h>
13#include <asm/kona-common/clk.h>
14#include <asm/arch/sysmap.h>
15
Jiandong Zheng3d310262015-07-09 14:26:40 -070016#include <usb.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010017#include <usb/dwc2_udc.h>
Jiandong Zheng3d310262015-07-09 14:26:40 -070018#include <g_dnl.h>
19
Darwin Rambo8ab2c482014-02-11 11:06:38 -080020#define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
21#define SECWATCHDOG_SDOGCR_EN_SHIFT 27
22#define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
23#define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
24#define SECWATCHDOG_SDOGCR_LD_SHIFT 0
25
Jiandong Zheng3d310262015-07-09 14:26:40 -070026#ifndef CONFIG_USB_SERIALNO
27#define CONFIG_USB_SERIALNO "1234567890"
28#endif
29
Darwin Rambo8ab2c482014-02-11 11:06:38 -080030DECLARE_GLOBAL_DATA_PTR;
31
32/*
33 * board_init - early hardware init
34 */
35int board_init(void)
36{
37 printf("Relocation Offset is: %08lx\n", gd->reloc_off);
38
39 /* adress of boot parameters */
40 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
41
42 clk_init();
43
44 return 0;
45}
46
47/*
48 * misc_init_r - miscellaneous platform dependent initializations
49 */
50int misc_init_r(void)
51{
52 /* Disable watchdog reset - watchdog unused */
53 writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
54 (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
55 (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
56 (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
57 (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
58
59 return 0;
60}
61
62/*
63 * dram_init - sets uboots idea of sdram size
64 */
65int dram_init(void)
66{
67 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
68 CONFIG_SYS_SDRAM_SIZE);
69 return 0;
70}
71
72/* This is called after dram_init() so use get_ram_size result */
Simon Glass2f949c32017-03-31 08:40:32 -060073int dram_init_banksize(void)
Darwin Rambo8ab2c482014-02-11 11:06:38 -080074{
75 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
76 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060077
78 return 0;
Darwin Rambo8ab2c482014-02-11 11:06:38 -080079}
80
Masahiro Yamada124f6ce2016-12-07 22:10:29 +090081#ifdef CONFIG_MMC_SDHCI_KONA
Darwin Rambo8ab2c482014-02-11 11:06:38 -080082/*
83 * mmc_init - Initializes mmc
84 */
85int board_mmc_init(bd_t *bis)
86{
87 int ret = 0;
88
89 /* Register eMMC - SDIO2 */
90 ret = kona_sdhci_init(1, 400000, 0);
91 if (ret)
92 return ret;
93
94 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
95 ret = kona_sdhci_init(3, 400000, 0);
96 return ret;
97}
98#endif
Jiandong Zheng3d310262015-07-09 14:26:40 -070099
100#ifdef CONFIG_USB_GADGET
Marek Vasut6939aca2015-12-04 02:23:29 +0100101static struct dwc2_plat_otg_data bcm_otg_data = {
Jiandong Zheng3d310262015-07-09 14:26:40 -0700102 .regs_otg = HSOTG_BASE_ADDR
103};
104
105int board_usb_init(int index, enum usb_init_type init)
106{
Marek Vasut01b61fa2015-12-04 02:26:33 +0100107 debug("%s: performing dwc2_udc_probe\n", __func__);
108 return dwc2_udc_probe(&bcm_otg_data);
Jiandong Zheng3d310262015-07-09 14:26:40 -0700109}
110
111int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
112{
113 debug("%s\n", __func__);
Simon Glass64b723f2017-08-03 12:22:12 -0600114 if (!env_get("serial#"))
Jiandong Zheng3d310262015-07-09 14:26:40 -0700115 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
116 return 0;
117}
118
119int g_dnl_get_board_bcd_device_number(int gcnum)
120{
121 debug("%s\n", __func__);
122 return 1;
123}
124
125int board_usb_cleanup(int index, enum usb_init_type init)
126{
127 debug("%s\n", __func__);
128 return 0;
129}
130#endif