sandbox: cros_ec: exynos: Drop use of cros_ec_get_error()
[platform/kernel/u-boot.git] / board / samsung / common / board.c
index 9be2950..6fd26a3 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2013 SAMSUNG Electronics
  * Rajeshwari Shinde <rajeshwari.s@samsung.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/power.h>
 #include <asm/arch/system.h>
-#include <power/pmic.h>
 #include <asm/arch/sromc.h>
 #include <lcd.h>
-#include <samsung/misc.h>
+#include <i2c.h>
 #include <usb.h>
+#include <dwc3-uboot.h>
+#include <samsung/misc.h>
+#include <dm/pinctrl.h>
+#include <dm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -96,7 +98,7 @@ int board_init(void)
 int dram_init(void)
 {
        unsigned int i;
-       u32 addr;
+       unsigned long addr;
 
        for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
                addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
@@ -105,10 +107,10 @@ int dram_init(void)
        return 0;
 }
 
-void dram_init_banksize(void)
+int dram_init_banksize(void)
 {
        unsigned int i;
-       u32 addr, size;
+       unsigned long addr, size;
 
        for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
                addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
@@ -117,10 +119,13 @@ void dram_init_banksize(void)
                gd->bd->bi_dram[i].start = addr;
                gd->bd->bi_dram[i].size = size;
        }
+
+       return 0;
 }
 
 static int board_uart_init(void)
 {
+#ifndef CONFIG_PINCTRL_EXYNOS
        int err, uart_id, ret = 0;
 
        for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) {
@@ -132,6 +137,9 @@ static int board_uart_init(void)
                }
        }
        return ret;
+#else
+       return 0;
+#endif
 }
 
 #ifdef CONFIG_BOARD_EARLY_INIT_F
@@ -151,25 +159,11 @@ int board_early_init_f(void)
        board_i2c_init(gd->fdt_blob);
 #endif
 
-#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
-
        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();
@@ -178,7 +172,6 @@ int power_init_board(void)
 }
 #endif
 
-#ifdef CONFIG_OF_CONTROL
 #ifdef CONFIG_SMC911X
 static int decode_sromc(const void *blob, struct fdt_sromc *config)
 {
@@ -256,10 +249,10 @@ int board_eth_init(bd_t *bis)
        return 0;
 }
 
-#ifdef CONFIG_GENERIC_MMC
+#ifdef CONFIG_MMC
 static int init_mmc(void)
 {
-#ifdef CONFIG_SDHCI
+#ifdef CONFIG_MMC_SDHCI
        return exynos_mmc_init(gd->fdt_blob);
 #else
        return 0;
@@ -268,7 +261,7 @@ static int init_mmc(void)
 
 static int init_dwmmc(void)
 {
-#ifdef CONFIG_DWMMC
+#ifdef CONFIG_MMC_DW
        return exynos_dwmmc_init(gd->fdt_blob);
 #else
        return 0;
@@ -303,25 +296,26 @@ int checkboard(void)
        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");
+       if (board_info)
+               printf("Type:  %s\n", board_info);
 #endif
        return 0;
 }
 #endif
-#endif /* CONFIG_OF_CONTROL */
 
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-       stdio_print_current_devices();
+       struct udevice *dev;
+       int ret;
 
-       if (cros_ec_get_error()) {
+       stdio_print_current_devices();
+       ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
+       if (ret && ret != -ENODEV) {
                /* Force console on */
                gd->flags &= ~GD_FLG_SILENT;
 
-               printf("cros-ec communications failure %d\n",
-                      cros_ec_get_error());
+               printf("cros-ec communications failure %d\n", ret);
                puts("\nPlease reset with Power+Refresh\n\n");
                panic("Cannot init cros-ec device");
                return -1;
@@ -358,8 +352,8 @@ void reset_misc(void)
        if (node < 0)
                return;
 
-       gpio_request_by_name_nodev(gd->fdt_blob, node, "reset-gpio", 0, &gpio,
-                                  GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(offset_to_ofnode(node), "reset-gpio", 0,
+                                  &gpio, GPIOD_IS_OUT);
 
        if (dm_gpio_is_valid(&gpio)) {
                /*
@@ -378,5 +372,8 @@ void reset_misc(void)
 
 int board_usb_cleanup(int index, enum usb_init_type init)
 {
+#ifdef CONFIG_USB_DWC3
+       dwc3_uboot_exit(index);
+#endif
        return 0;
 }