2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-11 19:06:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Broadcom Corporation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/mach-types.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2014-02-11 19:06:38 +00:00
|
|
|
#include <mmc.h>
|
|
|
|
#include <asm/kona-common/kona_sdhci.h>
|
|
|
|
#include <asm/kona-common/clk.h>
|
|
|
|
#include <asm/arch/sysmap.h>
|
|
|
|
|
2015-07-09 21:26:40 +00:00
|
|
|
#include <usb.h>
|
2015-12-04 01:51:20 +00:00
|
|
|
#include <usb/dwc2_udc.h>
|
2015-07-09 21:26:40 +00:00
|
|
|
#include <g_dnl.h>
|
|
|
|
|
2014-02-11 19:06:38 +00:00
|
|
|
#define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
|
|
|
|
#define SECWATCHDOG_SDOGCR_EN_SHIFT 27
|
|
|
|
#define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
|
|
|
|
#define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
|
|
|
|
#define SECWATCHDOG_SDOGCR_LD_SHIFT 0
|
|
|
|
|
2015-07-09 21:26:40 +00:00
|
|
|
#ifndef CONFIG_USB_SERIALNO
|
|
|
|
#define CONFIG_USB_SERIALNO "1234567890"
|
|
|
|
#endif
|
|
|
|
|
2014-02-11 19:06:38 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* board_init - early hardware init
|
|
|
|
*/
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
printf("Relocation Offset is: %08lx\n", gd->reloc_off);
|
|
|
|
|
|
|
|
/* adress of boot parameters */
|
|
|
|
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
|
|
|
|
|
|
|
clk_init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* misc_init_r - miscellaneous platform dependent initializations
|
|
|
|
*/
|
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
|
|
|
/* Disable watchdog reset - watchdog unused */
|
|
|
|
writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
|
|
|
|
(0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
|
|
|
|
(4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
|
|
|
|
(0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
|
|
|
|
(SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dram_init - sets uboots idea of sdram size
|
|
|
|
*/
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
|
|
|
gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
|
|
|
|
CONFIG_SYS_SDRAM_SIZE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is called after dram_init() so use get_ram_size result */
|
2017-03-31 14:40:32 +00:00
|
|
|
int dram_init_banksize(void)
|
2014-02-11 19:06:38 +00:00
|
|
|
{
|
|
|
|
gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
|
|
|
|
gd->bd->bi_dram[0].size = gd->ram_size;
|
2017-03-31 14:40:32 +00:00
|
|
|
|
|
|
|
return 0;
|
2014-02-11 19:06:38 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 13:10:29 +00:00
|
|
|
#ifdef CONFIG_MMC_SDHCI_KONA
|
2014-02-11 19:06:38 +00:00
|
|
|
/*
|
|
|
|
* mmc_init - Initializes mmc
|
|
|
|
*/
|
|
|
|
int board_mmc_init(bd_t *bis)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Register eMMC - SDIO2 */
|
|
|
|
ret = kona_sdhci_init(1, 400000, 0);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
|
|
|
|
ret = kona_sdhci_init(3, 400000, 0);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-09 21:26:40 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_USB_GADGET
|
2015-12-04 01:23:29 +00:00
|
|
|
static struct dwc2_plat_otg_data bcm_otg_data = {
|
2015-07-09 21:26:40 +00:00
|
|
|
.regs_otg = HSOTG_BASE_ADDR
|
|
|
|
};
|
|
|
|
|
|
|
|
int board_usb_init(int index, enum usb_init_type init)
|
|
|
|
{
|
2015-12-04 01:26:33 +00:00
|
|
|
debug("%s: performing dwc2_udc_probe\n", __func__);
|
|
|
|
return dwc2_udc_probe(&bcm_otg_data);
|
2015-07-09 21:26:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
|
|
|
|
{
|
|
|
|
debug("%s\n", __func__);
|
2017-08-03 18:22:12 +00:00
|
|
|
if (!env_get("serial#"))
|
2015-07-09 21:26:40 +00:00
|
|
|
g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int g_dnl_get_board_bcd_device_number(int gcnum)
|
|
|
|
{
|
|
|
|
debug("%s\n", __func__);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_usb_cleanup(int index, enum usb_init_type init)
|
|
|
|
{
|
|
|
|
debug("%s\n", __func__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|