Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2013 Broadcom Corporation. |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame^] | 7 | #include <init.h> |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <asm/mach-types.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 10 | #include <env.h> |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 11 | #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 | |
| 16 | #include <usb.h> |
| 17 | #include <usb/dwc2_udc.h> |
| 18 | #include <g_dnl.h> |
| 19 | |
| 20 | #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 | |
| 26 | #ifndef CONFIG_USB_SERIALNO |
| 27 | #define CONFIG_USB_SERIALNO "1234567890" |
| 28 | #endif |
| 29 | |
| 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
| 32 | /* |
| 33 | * board_init - early hardware init |
| 34 | */ |
| 35 | int 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 | */ |
| 50 | int misc_init_r(void) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | * dram_init - sets uboots idea of sdram size |
| 57 | */ |
| 58 | int dram_init(void) |
| 59 | { |
| 60 | gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, |
| 61 | CONFIG_SYS_SDRAM_SIZE); |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | /* This is called after dram_init() so use get_ram_size result */ |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 66 | int dram_init_banksize(void) |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 67 | { |
| 68 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 69 | gd->bd->bi_dram[0].size = gd->ram_size; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 70 | |
| 71 | return 0; |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Masahiro Yamada | 124f6ce | 2016-12-07 22:10:29 +0900 | [diff] [blame] | 74 | #ifdef CONFIG_MMC_SDHCI_KONA |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 75 | /* |
| 76 | * mmc_init - Initializes mmc |
| 77 | */ |
| 78 | int board_mmc_init(bd_t *bis) |
| 79 | { |
| 80 | int ret = 0; |
| 81 | |
| 82 | /* Register eMMC - SDIO2 */ |
| 83 | ret = kona_sdhci_init(1, 400000, 0); |
| 84 | if (ret) |
| 85 | return ret; |
| 86 | |
| 87 | /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */ |
| 88 | ret = kona_sdhci_init(3, 400000, 0); |
| 89 | return ret; |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | #ifdef CONFIG_USB_GADGET |
| 94 | static struct dwc2_plat_otg_data bcm_otg_data = { |
| 95 | .regs_otg = HSOTG_BASE_ADDR |
| 96 | }; |
| 97 | |
| 98 | int board_usb_init(int index, enum usb_init_type init) |
| 99 | { |
| 100 | debug("%s: performing dwc2_udc_probe\n", __func__); |
| 101 | return dwc2_udc_probe(&bcm_otg_data); |
| 102 | } |
| 103 | |
| 104 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) |
| 105 | { |
| 106 | debug("%s\n", __func__); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 107 | if (!env_get("serial#")) |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 108 | g_dnl_set_serialnumber(CONFIG_USB_SERIALNO); |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | int g_dnl_get_board_bcd_device_number(int gcnum) |
| 113 | { |
| 114 | debug("%s\n", __func__); |
| 115 | return 1; |
| 116 | } |
| 117 | |
| 118 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 119 | { |
| 120 | debug("%s\n", __func__); |
| 121 | return 0; |
| 122 | } |
| 123 | #endif |