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> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 9 | #include <asm/io.h> |
| 10 | #include <asm/mach-types.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 11 | #include <env.h> |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 12 | #include <mmc.h> |
| 13 | #include <asm/kona-common/kona_sdhci.h> |
| 14 | #include <asm/kona-common/clk.h> |
| 15 | #include <asm/arch/sysmap.h> |
| 16 | |
| 17 | #include <usb.h> |
| 18 | #include <usb/dwc2_udc.h> |
| 19 | #include <g_dnl.h> |
| 20 | |
| 21 | #define SECWATCHDOG_SDOGCR_OFFSET 0x00000000 |
| 22 | #define SECWATCHDOG_SDOGCR_EN_SHIFT 27 |
| 23 | #define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26 |
| 24 | #define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20 |
| 25 | #define SECWATCHDOG_SDOGCR_LD_SHIFT 0 |
| 26 | |
| 27 | #ifndef CONFIG_USB_SERIALNO |
| 28 | #define CONFIG_USB_SERIALNO "1234567890" |
| 29 | #endif |
| 30 | |
| 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
| 33 | /* |
| 34 | * board_init - early hardware init |
| 35 | */ |
| 36 | int board_init(void) |
| 37 | { |
| 38 | printf("Relocation Offset is: %08lx\n", gd->reloc_off); |
| 39 | |
| 40 | /* adress of boot parameters */ |
| 41 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 42 | |
| 43 | clk_init(); |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * misc_init_r - miscellaneous platform dependent initializations |
| 50 | */ |
| 51 | int misc_init_r(void) |
| 52 | { |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | * dram_init - sets uboots idea of sdram size |
| 58 | */ |
| 59 | int dram_init(void) |
| 60 | { |
| 61 | gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, |
| 62 | CONFIG_SYS_SDRAM_SIZE); |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | /* This is called after dram_init() so use get_ram_size result */ |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 67 | int dram_init_banksize(void) |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 68 | { |
| 69 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 70 | gd->bd->bi_dram[0].size = gd->ram_size; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 71 | |
| 72 | return 0; |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Masahiro Yamada | 124f6ce | 2016-12-07 22:10:29 +0900 | [diff] [blame] | 75 | #ifdef CONFIG_MMC_SDHCI_KONA |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 76 | /* |
| 77 | * mmc_init - Initializes mmc |
| 78 | */ |
| 79 | int board_mmc_init(bd_t *bis) |
| 80 | { |
| 81 | int ret = 0; |
| 82 | |
| 83 | /* Register eMMC - SDIO2 */ |
| 84 | ret = kona_sdhci_init(1, 400000, 0); |
| 85 | if (ret) |
| 86 | return ret; |
| 87 | |
| 88 | /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */ |
| 89 | ret = kona_sdhci_init(3, 400000, 0); |
| 90 | return ret; |
| 91 | } |
| 92 | #endif |
| 93 | |
| 94 | #ifdef CONFIG_USB_GADGET |
| 95 | static struct dwc2_plat_otg_data bcm_otg_data = { |
| 96 | .regs_otg = HSOTG_BASE_ADDR |
| 97 | }; |
| 98 | |
| 99 | int board_usb_init(int index, enum usb_init_type init) |
| 100 | { |
| 101 | debug("%s: performing dwc2_udc_probe\n", __func__); |
| 102 | return dwc2_udc_probe(&bcm_otg_data); |
| 103 | } |
| 104 | |
| 105 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) |
| 106 | { |
| 107 | debug("%s\n", __func__); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 108 | if (!env_get("serial#")) |
Steve Rae | 45f2c70 | 2016-06-02 15:10:56 -0700 | [diff] [blame] | 109 | g_dnl_set_serialnumber(CONFIG_USB_SERIALNO); |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | int g_dnl_get_board_bcd_device_number(int gcnum) |
| 114 | { |
| 115 | debug("%s\n", __func__); |
| 116 | return 1; |
| 117 | } |
| 118 | |
| 119 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 120 | { |
| 121 | debug("%s\n", __func__); |
| 122 | return 0; |
| 123 | } |
| 124 | #endif |