blob: 6faeb6a5154f9f78af646011e798fa7e9324a866 [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>
7#include <asm/io.h>
8#include <asm/mach-types.h>
9#include <mmc.h>
10#include <asm/kona-common/kona_sdhci.h>
11#include <asm/kona-common/clk.h>
12#include <asm/arch/sysmap.h>
13
Jiandong Zheng3d310262015-07-09 14:26:40 -070014#include <usb.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010015#include <usb/dwc2_udc.h>
Jiandong Zheng3d310262015-07-09 14:26:40 -070016#include <g_dnl.h>
17
Darwin Rambo8ab2c482014-02-11 11:06:38 -080018#define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
19#define SECWATCHDOG_SDOGCR_EN_SHIFT 27
20#define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
21#define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
22#define SECWATCHDOG_SDOGCR_LD_SHIFT 0
23
Jiandong Zheng3d310262015-07-09 14:26:40 -070024#ifndef CONFIG_USB_SERIALNO
25#define CONFIG_USB_SERIALNO "1234567890"
26#endif
27
Darwin Rambo8ab2c482014-02-11 11:06:38 -080028DECLARE_GLOBAL_DATA_PTR;
29
30/*
31 * board_init - early hardware init
32 */
33int board_init(void)
34{
35 printf("Relocation Offset is: %08lx\n", gd->reloc_off);
36
37 /* adress of boot parameters */
38 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
39
40 clk_init();
41
42 return 0;
43}
44
45/*
46 * misc_init_r - miscellaneous platform dependent initializations
47 */
48int misc_init_r(void)
49{
50 /* Disable watchdog reset - watchdog unused */
51 writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
52 (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
53 (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
54 (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
55 (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
56
57 return 0;
58}
59
60/*
61 * dram_init - sets uboots idea of sdram size
62 */
63int dram_init(void)
64{
65 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
66 CONFIG_SYS_SDRAM_SIZE);
67 return 0;
68}
69
70/* This is called after dram_init() so use get_ram_size result */
Simon Glass2f949c32017-03-31 08:40:32 -060071int dram_init_banksize(void)
Darwin Rambo8ab2c482014-02-11 11:06:38 -080072{
73 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
74 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060075
76 return 0;
Darwin Rambo8ab2c482014-02-11 11:06:38 -080077}
78
Masahiro Yamada124f6ce2016-12-07 22:10:29 +090079#ifdef CONFIG_MMC_SDHCI_KONA
Darwin Rambo8ab2c482014-02-11 11:06:38 -080080/*
81 * mmc_init - Initializes mmc
82 */
83int board_mmc_init(bd_t *bis)
84{
85 int ret = 0;
86
87 /* Register eMMC - SDIO2 */
88 ret = kona_sdhci_init(1, 400000, 0);
89 if (ret)
90 return ret;
91
92 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
93 ret = kona_sdhci_init(3, 400000, 0);
94 return ret;
95}
96#endif
Jiandong Zheng3d310262015-07-09 14:26:40 -070097
98#ifdef CONFIG_USB_GADGET
Marek Vasut6939aca2015-12-04 02:23:29 +010099static struct dwc2_plat_otg_data bcm_otg_data = {
Jiandong Zheng3d310262015-07-09 14:26:40 -0700100 .regs_otg = HSOTG_BASE_ADDR
101};
102
103int board_usb_init(int index, enum usb_init_type init)
104{
Marek Vasut01b61fa2015-12-04 02:26:33 +0100105 debug("%s: performing dwc2_udc_probe\n", __func__);
106 return dwc2_udc_probe(&bcm_otg_data);
Jiandong Zheng3d310262015-07-09 14:26:40 -0700107}
108
109int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
110{
111 debug("%s\n", __func__);
Simon Glass64b723f2017-08-03 12:22:12 -0600112 if (!env_get("serial#"))
Jiandong Zheng3d310262015-07-09 14:26:40 -0700113 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
114 return 0;
115}
116
117int g_dnl_get_board_bcd_device_number(int gcnum)
118{
119 debug("%s\n", __func__);
120 return 1;
121}
122
123int board_usb_cleanup(int index, enum usb_init_type init)
124{
125 debug("%s\n", __func__);
126 return 0;
127}
128#endif