dm: gpio: Add live tree support
[oweals/u-boot.git] / board / samsung / common / board.c
index 2e17da8a7a44766d8431ee8510c15f710caa2b92..88299f17e37dde596b70c7302c32013bd0f0cf6a 100644 (file)
 #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 <i2c.h>
+#include <usb.h>
+#include <dwc3-uboot.h>
 #include <samsung/misc.h>
+#include <dm/pinctrl.h>
+#include <dm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -95,7 +99,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);
@@ -104,10 +108,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);
@@ -116,10 +120,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++) {
@@ -131,6 +138,9 @@ static int board_uart_init(void)
                }
        }
        return ret;
+#else
+       return 0;
+#endif
 }
 
 #ifdef CONFIG_BOARD_EARLY_INIT_F
@@ -150,25 +160,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();
@@ -177,7 +173,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)
 {
@@ -255,10 +250,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;
@@ -267,7 +262,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;
@@ -302,13 +297,12 @@ 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)
@@ -329,18 +323,6 @@ int board_late_init(void)
 }
 #endif
 
-int arch_early_init_r(void)
-{
-#ifdef CONFIG_CROS_EC
-       if (cros_ec_board_init()) {
-               printf("%s: Failed to init EC\n", __func__);
-               return 0;
-       }
-#endif
-
-       return 0;
-}
-
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
@@ -369,8 +351,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)) {
                /*
@@ -386,3 +368,11 @@ void reset_misc(void)
                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;
+}