Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 SAMSUNG Electronics |
| 4 | * Rajeshwari Shinde <rajeshwari.s@samsung.com> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <cros_ec.h> |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 9 | #include <env.h> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 10 | #include <errno.h> |
| 11 | #include <fdtdec.h> |
Simon Glass | db41d65 | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 12 | #include <hang.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 13 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 14 | #include <log.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 15 | #include <net.h> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 16 | #include <spi.h> |
| 17 | #include <tmu.h> |
| 18 | #include <netdev.h> |
| 19 | #include <asm/io.h> |
Simon Glass | 903fd79 | 2014-10-20 19:48:37 -0600 | [diff] [blame] | 20 | #include <asm/gpio.h> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 21 | #include <asm/arch/board.h> |
| 22 | #include <asm/arch/cpu.h> |
| 23 | #include <asm/arch/dwmmc.h> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 24 | #include <asm/arch/mmc.h> |
| 25 | #include <asm/arch/pinmux.h> |
| 26 | #include <asm/arch/power.h> |
Ajay Kumar | f001717 | 2014-09-05 16:53:30 +0530 | [diff] [blame] | 27 | #include <asm/arch/system.h> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 28 | #include <asm/arch/sromc.h> |
Piotr Wilczek | 431a1c5 | 2014-03-07 14:59:45 +0100 | [diff] [blame] | 29 | #include <lcd.h> |
Przemyslaw Marczak | 622e5fe | 2015-04-20 20:07:50 +0200 | [diff] [blame] | 30 | #include <i2c.h> |
Marek Szyprowski | 86c8871 | 2020-01-17 14:02:44 +0100 | [diff] [blame] | 31 | #include <mmc.h> |
| 32 | #include <stdio_dev.h> |
Lukasz Majewski | 28f393c | 2015-03-03 17:32:03 +0100 | [diff] [blame] | 33 | #include <usb.h> |
Joonyoung Shim | 302a7d0 | 2015-05-22 18:14:24 +0200 | [diff] [blame] | 34 | #include <dwc3-uboot.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame^] | 35 | #include <linux/delay.h> |
Joonyoung Shim | 302a7d0 | 2015-05-22 18:14:24 +0200 | [diff] [blame] | 36 | #include <samsung/misc.h> |
Thomas Abraham | 6c15a2a | 2016-04-23 22:18:14 +0530 | [diff] [blame] | 37 | #include <dm/pinctrl.h> |
| 38 | #include <dm.h> |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 39 | |
| 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
Jeroen Hofstee | e7e60c1 | 2014-10-08 22:57:28 +0200 | [diff] [blame] | 42 | __weak int exynos_early_init_f(void) |
Piotr Wilczek | 8e5e1e6 | 2014-03-07 14:59:43 +0100 | [diff] [blame] | 43 | { |
| 44 | return 0; |
| 45 | } |
Piotr Wilczek | 8e5e1e6 | 2014-03-07 14:59:43 +0100 | [diff] [blame] | 46 | |
Jeroen Hofstee | e7e60c1 | 2014-10-08 22:57:28 +0200 | [diff] [blame] | 47 | __weak int exynos_power_init(void) |
Piotr Wilczek | 8e5e1e6 | 2014-03-07 14:59:43 +0100 | [diff] [blame] | 48 | { |
| 49 | return 0; |
| 50 | } |
Piotr Wilczek | 8e5e1e6 | 2014-03-07 14:59:43 +0100 | [diff] [blame] | 51 | |
Marek Szyprowski | 86c8871 | 2020-01-17 14:02:44 +0100 | [diff] [blame] | 52 | /** |
| 53 | * get_boot_mmc_dev() - read boot MMC device id from XOM[7:5] pins. |
| 54 | */ |
| 55 | static int get_boot_mmc_dev(void) |
| 56 | { |
| 57 | u32 mode = readl(EXYNOS4_OP_MODE) & 0x1C; |
| 58 | |
| 59 | if (mode == 0x04) |
| 60 | return 2; /* MMC2: SD */ |
| 61 | |
| 62 | /* MMC0: eMMC or unknown */ |
| 63 | return 0; |
| 64 | } |
| 65 | |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 66 | #if defined CONFIG_EXYNOS_TMU |
| 67 | /* Boot Time Thermal Analysis for SoC temperature threshold breach */ |
| 68 | static void boot_temp_check(void) |
| 69 | { |
| 70 | int temp; |
| 71 | |
| 72 | switch (tmu_monitor(&temp)) { |
| 73 | case TMU_STATUS_NORMAL: |
| 74 | break; |
| 75 | case TMU_STATUS_TRIPPED: |
| 76 | /* |
| 77 | * Status TRIPPED ans WARNING means corresponding threshold |
| 78 | * breach |
| 79 | */ |
| 80 | puts("EXYNOS_TMU: TRIPPING! Device power going down ...\n"); |
| 81 | set_ps_hold_ctrl(); |
| 82 | hang(); |
| 83 | break; |
| 84 | case TMU_STATUS_WARNING: |
| 85 | puts("EXYNOS_TMU: WARNING! Temperature very high\n"); |
| 86 | break; |
| 87 | case TMU_STATUS_INIT: |
| 88 | /* |
| 89 | * TMU_STATUS_INIT means something is wrong with temperature |
| 90 | * sensing and TMU status was changed back from NORMAL to INIT. |
| 91 | */ |
| 92 | puts("EXYNOS_TMU: WARNING! Temperature sensing not done\n"); |
| 93 | break; |
| 94 | default: |
| 95 | debug("EXYNOS_TMU: Unknown TMU state\n"); |
| 96 | } |
| 97 | } |
| 98 | #endif |
| 99 | |
| 100 | int board_init(void) |
| 101 | { |
| 102 | gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL); |
| 103 | #if defined CONFIG_EXYNOS_TMU |
| 104 | if (tmu_init(gd->fdt_blob) != TMU_STATUS_NORMAL) { |
| 105 | debug("%s: Failed to init TMU\n", __func__); |
| 106 | return -1; |
| 107 | } |
| 108 | boot_temp_check(); |
| 109 | #endif |
Przemyslaw Marczak | a0643e2 | 2015-02-17 14:50:25 +0100 | [diff] [blame] | 110 | #ifdef CONFIG_TZSW_RESERVED_DRAM_SIZE |
| 111 | /* The last few MB of memory can be reserved for secure firmware */ |
| 112 | ulong size = CONFIG_TZSW_RESERVED_DRAM_SIZE; |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 113 | |
Przemyslaw Marczak | a0643e2 | 2015-02-17 14:50:25 +0100 | [diff] [blame] | 114 | gd->ram_size -= size; |
| 115 | gd->bd->bi_dram[CONFIG_NR_DRAM_BANKS - 1].size -= size; |
| 116 | #endif |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 117 | return exynos_init(); |
| 118 | } |
| 119 | |
| 120 | int dram_init(void) |
| 121 | { |
Ćukasz Majewski | c8b71a3 | 2015-03-04 10:54:48 +0100 | [diff] [blame] | 122 | unsigned int i; |
Thomas Abraham | 6c15a2a | 2016-04-23 22:18:14 +0530 | [diff] [blame] | 123 | unsigned long addr; |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 124 | |
| 125 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 126 | addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE); |
| 127 | gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE); |
| 128 | } |
| 129 | return 0; |
| 130 | } |
| 131 | |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 132 | int dram_init_banksize(void) |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 133 | { |
Ćukasz Majewski | c8b71a3 | 2015-03-04 10:54:48 +0100 | [diff] [blame] | 134 | unsigned int i; |
Thomas Abraham | 6c15a2a | 2016-04-23 22:18:14 +0530 | [diff] [blame] | 135 | unsigned long addr, size; |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 136 | |
| 137 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 138 | addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE); |
| 139 | size = get_ram_size((long *)addr, SDRAM_BANK_SIZE); |
| 140 | |
| 141 | gd->bd->bi_dram[i].start = addr; |
| 142 | gd->bd->bi_dram[i].size = size; |
| 143 | } |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 144 | |
| 145 | return 0; |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | static int board_uart_init(void) |
| 149 | { |
Thomas Abraham | 6c15a2a | 2016-04-23 22:18:14 +0530 | [diff] [blame] | 150 | #ifndef CONFIG_PINCTRL_EXYNOS |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 151 | int err, uart_id, ret = 0; |
| 152 | |
| 153 | for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) { |
| 154 | err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE); |
| 155 | if (err) { |
| 156 | debug("UART%d not configured\n", |
| 157 | (uart_id - PERIPH_ID_UART0)); |
| 158 | ret |= err; |
| 159 | } |
| 160 | } |
| 161 | return ret; |
Thomas Abraham | 6c15a2a | 2016-04-23 22:18:14 +0530 | [diff] [blame] | 162 | #else |
| 163 | return 0; |
| 164 | #endif |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 168 | int board_early_init_f(void) |
| 169 | { |
| 170 | int err; |
Przemyslaw Marczak | d50c41e | 2014-09-01 13:50:49 +0200 | [diff] [blame] | 171 | #ifdef CONFIG_BOARD_TYPES |
| 172 | set_board_type(); |
| 173 | #endif |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 174 | err = board_uart_init(); |
| 175 | if (err) { |
| 176 | debug("UART init failed\n"); |
| 177 | return err; |
| 178 | } |
| 179 | |
| 180 | #ifdef CONFIG_SYS_I2C_INIT_BOARD |
| 181 | board_i2c_init(gd->fdt_blob); |
| 182 | #endif |
Ajay Kumar | f001717 | 2014-09-05 16:53:30 +0530 | [diff] [blame] | 183 | |
Piotr Wilczek | 8e5e1e6 | 2014-03-07 14:59:43 +0100 | [diff] [blame] | 184 | return exynos_early_init_f(); |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 185 | } |
| 186 | #endif |
| 187 | |
Przemyslaw Marczak | 622e5fe | 2015-04-20 20:07:50 +0200 | [diff] [blame] | 188 | #if defined(CONFIG_POWER) || defined(CONFIG_DM_PMIC) |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 189 | int power_init_board(void) |
| 190 | { |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 191 | set_ps_hold_ctrl(); |
| 192 | |
Piotr Wilczek | 8e5e1e6 | 2014-03-07 14:59:43 +0100 | [diff] [blame] | 193 | return exynos_power_init(); |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 194 | } |
| 195 | #endif |
| 196 | |
Piotr Wilczek | 431a1c5 | 2014-03-07 14:59:45 +0100 | [diff] [blame] | 197 | #ifdef CONFIG_SMC911X |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 198 | static int decode_sromc(const void *blob, struct fdt_sromc *config) |
| 199 | { |
| 200 | int err; |
| 201 | int node; |
| 202 | |
| 203 | node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SROMC); |
| 204 | if (node < 0) { |
| 205 | debug("Could not find SROMC node\n"); |
| 206 | return node; |
| 207 | } |
| 208 | |
| 209 | config->bank = fdtdec_get_int(blob, node, "bank", 0); |
| 210 | config->width = fdtdec_get_int(blob, node, "width", 2); |
| 211 | |
| 212 | err = fdtdec_get_int_array(blob, node, "srom-timing", config->timing, |
| 213 | FDT_SROM_TIMING_COUNT); |
| 214 | if (err < 0) { |
| 215 | debug("Could not decode SROMC configuration Error: %s\n", |
| 216 | fdt_strerror(err)); |
| 217 | return -FDT_ERR_NOTFOUND; |
| 218 | } |
| 219 | return 0; |
| 220 | } |
Piotr Wilczek | 431a1c5 | 2014-03-07 14:59:45 +0100 | [diff] [blame] | 221 | #endif |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 222 | |
| 223 | int board_eth_init(bd_t *bis) |
| 224 | { |
| 225 | #ifdef CONFIG_SMC911X |
| 226 | u32 smc_bw_conf, smc_bc_conf; |
| 227 | struct fdt_sromc config; |
| 228 | fdt_addr_t base_addr; |
| 229 | int node; |
| 230 | |
| 231 | node = decode_sromc(gd->fdt_blob, &config); |
| 232 | if (node < 0) { |
| 233 | debug("%s: Could not find sromc configuration\n", __func__); |
| 234 | return 0; |
| 235 | } |
| 236 | node = fdtdec_next_compatible(gd->fdt_blob, node, COMPAT_SMSC_LAN9215); |
| 237 | if (node < 0) { |
| 238 | debug("%s: Could not find lan9215 configuration\n", __func__); |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | /* We now have a node, so any problems from now on are errors */ |
| 243 | base_addr = fdtdec_get_addr(gd->fdt_blob, node, "reg"); |
| 244 | if (base_addr == FDT_ADDR_T_NONE) { |
| 245 | debug("%s: Could not find lan9215 address\n", __func__); |
| 246 | return -1; |
| 247 | } |
| 248 | |
| 249 | /* Ethernet needs data bus width of 16 bits */ |
| 250 | if (config.width != 2) { |
| 251 | debug("%s: Unsupported bus width %d\n", __func__, |
| 252 | config.width); |
| 253 | return -1; |
| 254 | } |
| 255 | smc_bw_conf = SROMC_DATA16_WIDTH(config.bank) |
| 256 | | SROMC_BYTE_ENABLE(config.bank); |
| 257 | |
| 258 | smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) | |
| 259 | SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) | |
| 260 | SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) | |
| 261 | SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) | |
| 262 | SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) | |
| 263 | SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) | |
| 264 | SROMC_BC_PMC(config.timing[FDT_SROM_PMC]); |
| 265 | |
| 266 | /* Select and configure the SROMC bank */ |
| 267 | exynos_pinmux_config(PERIPH_ID_SROMC, config.bank); |
| 268 | s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf); |
| 269 | return smc911x_initialize(0, base_addr); |
| 270 | #endif |
| 271 | return 0; |
| 272 | } |
| 273 | |
Krzysztof Kozlowski | 345a536 | 2019-03-06 19:37:52 +0100 | [diff] [blame] | 274 | #if defined(CONFIG_DISPLAY_BOARDINFO) || defined(CONFIG_DISPLAY_BOARDINFO_LATE) |
Piotr Wilczek | 4c1dd99 | 2014-03-07 14:59:42 +0100 | [diff] [blame] | 275 | int checkboard(void) |
| 276 | { |
Simon Glass | a42ff92 | 2019-01-11 18:37:07 -0700 | [diff] [blame] | 277 | if (IS_ENABLED(CONFIG_BOARD_TYPES)) { |
Krzysztof Kozlowski | e3ee4be | 2019-03-06 19:37:51 +0100 | [diff] [blame] | 278 | const char *board_info; |
| 279 | |
| 280 | if (IS_ENABLED(CONFIG_DISPLAY_BOARDINFO_LATE)) { |
| 281 | /* |
| 282 | * Printing type requires having revision, although |
| 283 | * this will succeed only if done late. |
| 284 | * Otherwise revision will be set in misc_init_r(). |
| 285 | */ |
| 286 | set_board_revision(); |
| 287 | } |
| 288 | |
| 289 | board_info = get_board_type(); |
Piotr Wilczek | 4c1dd99 | 2014-03-07 14:59:42 +0100 | [diff] [blame] | 290 | |
Simon Glass | a42ff92 | 2019-01-11 18:37:07 -0700 | [diff] [blame] | 291 | if (board_info) |
| 292 | printf("Type: %s\n", board_info); |
| 293 | } |
| 294 | |
Piotr Wilczek | 4c1dd99 | 2014-03-07 14:59:42 +0100 | [diff] [blame] | 295 | return 0; |
| 296 | } |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 297 | #endif |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 298 | |
| 299 | #ifdef CONFIG_BOARD_LATE_INIT |
| 300 | int board_late_init(void) |
| 301 | { |
Simon Glass | a2a63a3 | 2018-11-06 15:21:26 -0700 | [diff] [blame] | 302 | struct udevice *dev; |
| 303 | int ret; |
Marek Szyprowski | 86c8871 | 2020-01-17 14:02:44 +0100 | [diff] [blame] | 304 | int mmcbootdev = get_boot_mmc_dev(); |
| 305 | char mmcbootdev_str[16]; |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 306 | |
Simon Glass | a2a63a3 | 2018-11-06 15:21:26 -0700 | [diff] [blame] | 307 | stdio_print_current_devices(); |
| 308 | ret = uclass_first_device_err(UCLASS_CROS_EC, &dev); |
| 309 | if (ret && ret != -ENODEV) { |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 310 | /* Force console on */ |
| 311 | gd->flags &= ~GD_FLG_SILENT; |
| 312 | |
Simon Glass | a2a63a3 | 2018-11-06 15:21:26 -0700 | [diff] [blame] | 313 | printf("cros-ec communications failure %d\n", ret); |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 314 | puts("\nPlease reset with Power+Refresh\n\n"); |
| 315 | panic("Cannot init cros-ec device"); |
| 316 | return -1; |
| 317 | } |
Marek Szyprowski | 86c8871 | 2020-01-17 14:02:44 +0100 | [diff] [blame] | 318 | |
| 319 | printf("Boot device: MMC(%u)\n", mmcbootdev); |
| 320 | sprintf(mmcbootdev_str, "%u", mmcbootdev); |
| 321 | env_set("mmcbootdev", mmcbootdev_str); |
| 322 | |
Rajeshwari Birje | 71ebb33 | 2013-12-26 09:44:17 +0530 | [diff] [blame] | 323 | return 0; |
| 324 | } |
| 325 | #endif |
| 326 | |
Piotr Wilczek | 431a1c5 | 2014-03-07 14:59:45 +0100 | [diff] [blame] | 327 | #ifdef CONFIG_MISC_INIT_R |
| 328 | int misc_init_r(void) |
| 329 | { |
Krzysztof Kozlowski | e3ee4be | 2019-03-06 19:37:51 +0100 | [diff] [blame] | 330 | if (IS_ENABLED(CONFIG_BOARD_TYPES) && |
| 331 | !IS_ENABLED(CONFIG_DISPLAY_BOARDINFO_LATE)) { |
| 332 | /* |
| 333 | * If revision was not set by late display boardinfo, |
| 334 | * set it here. At this point regulators should be already |
| 335 | * available. |
| 336 | */ |
| 337 | set_board_revision(); |
| 338 | } |
| 339 | |
Piotr Wilczek | 431a1c5 | 2014-03-07 14:59:45 +0100 | [diff] [blame] | 340 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 341 | set_board_info(); |
| 342 | #endif |
| 343 | #ifdef CONFIG_LCD_MENU |
| 344 | keys_init(); |
| 345 | check_boot_mode(); |
| 346 | #endif |
| 347 | #ifdef CONFIG_CMD_BMP |
| 348 | if (panel_info.logo_on) |
| 349 | draw_logo(); |
| 350 | #endif |
| 351 | return 0; |
| 352 | } |
| 353 | #endif |
Joonyoung Shim | aa8e00f | 2015-01-15 11:45:56 +0900 | [diff] [blame] | 354 | |
| 355 | void reset_misc(void) |
| 356 | { |
| 357 | struct gpio_desc gpio = {}; |
| 358 | int node; |
| 359 | |
| 360 | node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, |
| 361 | "samsung,emmc-reset"); |
| 362 | if (node < 0) |
| 363 | return; |
| 364 | |
Simon Glass | 150c5af | 2017-05-30 21:47:09 -0600 | [diff] [blame] | 365 | gpio_request_by_name_nodev(offset_to_ofnode(node), "reset-gpio", 0, |
| 366 | &gpio, GPIOD_IS_OUT); |
Joonyoung Shim | aa8e00f | 2015-01-15 11:45:56 +0900 | [diff] [blame] | 367 | |
| 368 | if (dm_gpio_is_valid(&gpio)) { |
| 369 | /* |
| 370 | * Reset eMMC |
| 371 | * |
| 372 | * FIXME: Need to optimize delay time. Minimum 1usec pulse is |
| 373 | * required by 'JEDEC Standard No.84-A441' (eMMC) |
| 374 | * document but real delay time is expected to greater |
| 375 | * than 1usec. |
| 376 | */ |
| 377 | dm_gpio_set_value(&gpio, 0); |
| 378 | mdelay(10); |
| 379 | dm_gpio_set_value(&gpio, 1); |
| 380 | } |
| 381 | } |
Lukasz Majewski | 28f393c | 2015-03-03 17:32:03 +0100 | [diff] [blame] | 382 | |
| 383 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 384 | { |
Joonyoung Shim | 302a7d0 | 2015-05-22 18:14:24 +0200 | [diff] [blame] | 385 | #ifdef CONFIG_USB_DWC3 |
| 386 | dwc3_uboot_exit(index); |
| 387 | #endif |
Lukasz Majewski | 28f393c | 2015-03-03 17:32:03 +0100 | [diff] [blame] | 388 | return 0; |
| 389 | } |
Marek Szyprowski | 86c8871 | 2020-01-17 14:02:44 +0100 | [diff] [blame] | 390 | |
| 391 | int mmc_get_env_dev(void) |
| 392 | { |
| 393 | return get_boot_mmc_dev(); |
| 394 | } |