blob: 43726f79bde3c36fda8463a4c728c6db6d5e2a59 [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>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Darwin Rambo8ab2c482014-02-11 11:06:38 -080010#include <asm/io.h>
11#include <asm/mach-types.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -060012#include <env.h>
Darwin Rambo8ab2c482014-02-11 11:06:38 -080013#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
Jiandong Zheng3d310262015-07-09 14:26:40 -070018#include <usb.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010019#include <usb/dwc2_udc.h>
Jiandong Zheng3d310262015-07-09 14:26:40 -070020#include <g_dnl.h>
21
Darwin Rambo8ab2c482014-02-11 11:06:38 -080022#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
Jiandong Zheng3d310262015-07-09 14:26:40 -070028#ifndef CONFIG_USB_SERIALNO
29#define CONFIG_USB_SERIALNO "1234567890"
30#endif
31
Darwin Rambo8ab2c482014-02-11 11:06:38 -080032DECLARE_GLOBAL_DATA_PTR;
33
34/*
35 * board_init - early hardware init
36 */
37int 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 */
52int misc_init_r(void)
53{
54 /* Disable watchdog reset - watchdog unused */
55 writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
56 (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
57 (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
58 (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
59 (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
60
61 return 0;
62}
63
64/*
65 * dram_init - sets uboots idea of sdram size
66 */
67int dram_init(void)
68{
69 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
70 CONFIG_SYS_SDRAM_SIZE);
71 return 0;
72}
73
74/* This is called after dram_init() so use get_ram_size result */
Simon Glass2f949c32017-03-31 08:40:32 -060075int dram_init_banksize(void)
Darwin Rambo8ab2c482014-02-11 11:06:38 -080076{
77 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
78 gd->bd->bi_dram[0].size = gd->ram_size;
Simon Glass2f949c32017-03-31 08:40:32 -060079
80 return 0;
Darwin Rambo8ab2c482014-02-11 11:06:38 -080081}
82
Masahiro Yamada124f6ce2016-12-07 22:10:29 +090083#ifdef CONFIG_MMC_SDHCI_KONA
Darwin Rambo8ab2c482014-02-11 11:06:38 -080084/*
85 * mmc_init - Initializes mmc
86 */
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090087int board_mmc_init(struct bd_info *bis)
Darwin Rambo8ab2c482014-02-11 11:06:38 -080088{
89 int ret = 0;
90
91 /* Register eMMC - SDIO2 */
92 ret = kona_sdhci_init(1, 400000, 0);
93 if (ret)
94 return ret;
95
96 /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
97 ret = kona_sdhci_init(3, 400000, 0);
98 return ret;
99}
100#endif
Jiandong Zheng3d310262015-07-09 14:26:40 -0700101
102#ifdef CONFIG_USB_GADGET
Marek Vasut6939aca2015-12-04 02:23:29 +0100103static struct dwc2_plat_otg_data bcm_otg_data = {
Jiandong Zheng3d310262015-07-09 14:26:40 -0700104 .regs_otg = HSOTG_BASE_ADDR
105};
106
107int board_usb_init(int index, enum usb_init_type init)
108{
Marek Vasut01b61fa2015-12-04 02:26:33 +0100109 debug("%s: performing dwc2_udc_probe\n", __func__);
110 return dwc2_udc_probe(&bcm_otg_data);
Jiandong Zheng3d310262015-07-09 14:26:40 -0700111}
112
113int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
114{
115 debug("%s\n", __func__);
Simon Glass64b723f2017-08-03 12:22:12 -0600116 if (!env_get("serial#"))
Jiandong Zheng3d310262015-07-09 14:26:40 -0700117 g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
118 return 0;
119}
120
121int g_dnl_get_board_bcd_device_number(int gcnum)
122{
123 debug("%s\n", __func__);
124 return 1;
125}
126
127int board_usb_cleanup(int index, enum usb_init_type init)
128{
129 debug("%s\n", __func__);
130 return 0;
131}
132#endif