X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=board%2Fsamsung%2Fcommon%2Fboard.c;h=1a4e8c9c99a1d6520cb824052cd19f004ccc0760;hb=2911bd1858d11308164b0b33de4ea0e8994d3edf;hp=e95e9c46198861cdf08a1f1d7526942e5ba3dba8;hpb=431a1c569c56ee8f4c0c78015b1a53b64784ff53;p=oweals%2Fu-boot.git diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index e95e9c4619..1a4e8c9c99 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -13,40 +13,32 @@ #include #include #include +#include #include #include #include -#include #include #include #include -#include +#include #include #include +#include +#include +#include #include DECLARE_GLOBAL_DATA_PTR; -struct local_info { - struct cros_ec_dev *cros_ec_dev; /* Pointer to cros_ec device */ - int cros_ec_err; /* Error for cros_ec, 0 if ok */ -}; - -static struct local_info local; - -int __exynos_early_init_f(void) +__weak int exynos_early_init_f(void) { return 0; } -int exynos_early_init_f(void) - __attribute__((weak, alias("__exynos_early_init_f"))); -int __exynos_power_init(void) +__weak int exynos_power_init(void) { return 0; } -int exynos_power_init(void) - __attribute__((weak, alias("__exynos_power_init"))); #if defined CONFIG_EXYNOS_TMU /* Boot Time Thermal Analysis for SoC temperature threshold breach */ @@ -92,16 +84,19 @@ int board_init(void) } boot_temp_check(); #endif +#ifdef CONFIG_TZSW_RESERVED_DRAM_SIZE + /* The last few MB of memory can be reserved for secure firmware */ + ulong size = CONFIG_TZSW_RESERVED_DRAM_SIZE; -#ifdef CONFIG_EXYNOS_SPI - spi_init(); + gd->ram_size -= size; + gd->bd->bi_dram[CONFIG_NR_DRAM_BANKS - 1].size -= size; #endif return exynos_init(); } int dram_init(void) { - int i; + unsigned int i; u32 addr; for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { @@ -113,7 +108,7 @@ int dram_init(void) void dram_init_banksize(void) { - int i; + unsigned int i; u32 addr, size; for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { @@ -144,7 +139,9 @@ static int board_uart_init(void) int board_early_init_f(void) { int err; - +#ifdef CONFIG_BOARD_TYPES + set_board_type(); +#endif err = board_uart_init(); if (err) { debug("UART init failed\n"); @@ -155,27 +152,25 @@ int board_early_init_f(void) board_i2c_init(gd->fdt_blob); #endif - return exynos_early_init_f(); -} +#if defined(CONFIG_OF_CONTROL) && defined(CONFIG_EXYNOS_FB) +/* + * board_init_f(arch/arm/lib/board.c) calls lcd_setmem() which needs + * panel_info.vl_col, panel_info.vl_row and panel_info.vl_bpix, to reserve + * FB memory at a very early stage. So, we need to fill panel_info.vl_col, + * panel_info.vl_row and panel_info.vl_bpix before lcd_setmem() is called. + */ + err = exynos_lcd_early_init(gd->fdt_blob); + if (err) { + debug("LCD early init failed\n"); + return err; + } #endif -struct cros_ec_dev *board_get_cros_ec_dev(void) -{ - return local.cros_ec_dev; -} - -#ifdef CONFIG_CROS_EC -static int board_init_cros_ec_devices(const void *blob) -{ - local.cros_ec_err = cros_ec_init(blob, &local.cros_ec_dev); - if (local.cros_ec_err) - return -1; /* Will report in board_late_init() */ - - return 0; + return exynos_early_init_f(); } #endif -#if defined(CONFIG_POWER) +#if defined(CONFIG_POWER) || defined(CONFIG_DM_PMIC) int power_init_board(void) { set_ps_hold_ctrl(); @@ -263,22 +258,38 @@ int board_eth_init(bd_t *bis) } #ifdef CONFIG_GENERIC_MMC +static int init_mmc(void) +{ +#ifdef CONFIG_SDHCI + return exynos_mmc_init(gd->fdt_blob); +#else + return 0; +#endif +} + +static int init_dwmmc(void) +{ +#ifdef CONFIG_DWMMC + return exynos_dwmmc_init(gd->fdt_blob); +#else + return 0; +#endif +} + int board_mmc_init(bd_t *bis) { int ret; -#ifdef CONFIG_SDHCI - /* mmc initializattion for available channels */ - ret = exynos_mmc_init(gd->fdt_blob); + if (get_boot_mode() == BOOT_MODE_SD) { + ret = init_mmc(); + ret |= init_dwmmc(); + } else { + ret = init_dwmmc(); + ret |= init_mmc(); + } + if (ret) debug("mmc init failed\n"); -#endif -#ifdef CONFIG_DWMMC - /* dwmmc initializattion for available channels */ - ret = exynos_dwmmc_init(gd->fdt_blob); - if (ret) - debug("dwmmc init failed\n"); -#endif return ret; } @@ -287,11 +298,15 @@ int board_mmc_init(bd_t *bis) #ifdef CONFIG_DISPLAY_BOARDINFO int checkboard(void) { - const char *board_name; + const char *board_info; - board_name = fdt_getprop(gd->fdt_blob, 0, "model", NULL); - printf("Board: %s\n", board_name ? board_name : "unknown"); + board_info = fdt_getprop(gd->fdt_blob, 0, "model", NULL); + printf("Board: %s\n", board_info ? board_info : "unknown"); +#ifdef CONFIG_BOARD_TYPES + board_info = get_board_type(); + printf("Model: %s\n", board_info ? board_info : "unknown"); +#endif return 0; } #endif @@ -302,12 +317,12 @@ int board_late_init(void) { stdio_print_current_devices(); - if (local.cros_ec_err) { + if (cros_ec_get_error()) { /* Force console on */ gd->flags &= ~GD_FLG_SILENT; printf("cros-ec communications failure %d\n", - local.cros_ec_err); + cros_ec_get_error()); puts("\nPlease reset with Power+Refresh\n\n"); panic("Cannot init cros-ec device"); return -1; @@ -316,18 +331,6 @@ int board_late_init(void) } #endif -int arch_early_init_r(void) -{ -#ifdef CONFIG_CROS_EC - if (board_init_cros_ec_devices(gd->fdt_blob)) { - printf("%s: Failed to init EC\n", __func__); - return 0; - } -#endif - - return 0; -} - #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { @@ -345,3 +348,39 @@ int misc_init_r(void) return 0; } #endif + +void reset_misc(void) +{ + struct gpio_desc gpio = {}; + int node; + + node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, + "samsung,emmc-reset"); + if (node < 0) + return; + + gpio_request_by_name_nodev(gd->fdt_blob, node, "reset-gpio", 0, &gpio, + GPIOD_IS_OUT); + + if (dm_gpio_is_valid(&gpio)) { + /* + * Reset eMMC + * + * FIXME: Need to optimize delay time. Minimum 1usec pulse is + * required by 'JEDEC Standard No.84-A441' (eMMC) + * document but real delay time is expected to greater + * than 1usec. + */ + dm_gpio_set_value(&gpio, 0); + mdelay(10); + dm_gpio_set_value(&gpio, 1); + } +} + +int board_usb_cleanup(int index, enum usb_init_type init) +{ +#ifdef CONFIG_USB_DWC3 + dwc3_uboot_exit(index); +#endif + return 0; +}