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