blob: 87616386cb84099916518f3242a179066b50a525 [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>
Simon Glass0af6e2d2019-08-01 09:46:52 -06009#include <env.h>
Darwin Rambo8ab2c482014-02-11 11:06:38 -080010#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
Jiandong Zheng3d310262015-07-09 14:26:40 -070015#include <usb.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010016#include <usb/dwc2_udc.h>
Jiandong Zheng3d310262015-07-09 14:26:40 -070017#include <g_dnl.h>
18
Darwin Rambo8ab2c482014-02-11 11:06:38 -080019#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
Jiandong Zheng3d310262015-07-09 14:26:40 -070025#ifndef CONFIG_USB_SERIALNO
26#define CONFIG_USB_SERIALNO "1234567890"
27#endif
28
Darwin Rambo8ab2c482014-02-11 11:06:38 -080029DECLARE_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 /* Disable watchdog reset - watchdog unused */
52 writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
53 (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
54 (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
55 (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
56 (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
57
58 return 0;
59}
60
61/*
62 * dram_init - sets uboots idea of sdram size
63 */
64int dram_init(void)
65{
66 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
67 CONFIG_SYS_SDRAM_SIZE);
68 return 0;
69}
70
71/* This is called after dram_init() so use get_ram_size result */
Simon Glass2f949c32017-03-31 08:40:32 -060072int dram_init_banksize(void)
Darwin Rambo8ab2c482014-02-11 11:06:38 -080073{
74 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
75 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060076
77 return 0;
Darwin Rambo8ab2c482014-02-11 11:06:38 -080078}
79
Masahiro Yamada124f6ce2016-12-07 22:10:29 +090080#ifdef CONFIG_MMC_SDHCI_KONA
Darwin Rambo8ab2c482014-02-11 11:06:38 -080081/*
82 * mmc_init - Initializes mmc
83 */
84int board_mmc_init(bd_t *bis)
85{
86 int ret = 0;
87
88 /* Register eMMC - SDIO2 */
89 ret = kona_sdhci_init(1, 400000, 0);
90 if (ret)
91 return ret;
92
93 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
94 ret = kona_sdhci_init(3, 400000, 0);
95 return ret;
96}
97#endif
Jiandong Zheng3d310262015-07-09 14:26:40 -070098
99#ifdef CONFIG_USB_GADGET
Marek Vasut6939aca2015-12-04 02:23:29 +0100100static struct dwc2_plat_otg_data bcm_otg_data = {
Jiandong Zheng3d310262015-07-09 14:26:40 -0700101 .regs_otg = HSOTG_BASE_ADDR
102};
103
104int board_usb_init(int index, enum usb_init_type init)
105{
Marek Vasut01b61fa2015-12-04 02:26:33 +0100106 debug("%s: performing dwc2_udc_probe\n", __func__);
107 return dwc2_udc_probe(&bcm_otg_data);
Jiandong Zheng3d310262015-07-09 14:26:40 -0700108}
109
110int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
111{
112 debug("%s\n", __func__);
Simon Glass64b723f2017-08-03 12:22:12 -0600113 if (!env_get("serial#"))
Jiandong Zheng3d310262015-07-09 14:26:40 -0700114 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
115 return 0;
116}
117
118int g_dnl_get_board_bcd_device_number(int gcnum)
119{
120 debug("%s\n", __func__);
121 return 1;
122}
123
124int board_usb_cleanup(int index, enum usb_init_type init)
125{
126 debug("%s\n", __func__);
127 return 0;
128}
129#endif