Merge branch 'master' of git://www.denx.de/git/u-boot-cfi-flash
[platform/kernel/u-boot.git] / board / samsung / smdk5250 / exynos5-dt.c
index 8131505..bb4a82f 100644 (file)
@@ -1,26 +1,11 @@
 /*
  * Copyright (C) 2012 Samsung Electronics
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <cros_ec.h>
 #include <fdtdec.h>
 #include <asm/io.h>
 #include <errno.h>
@@ -69,6 +54,13 @@ static void boot_temp_check(void)
 }
 #endif
 
+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;
+
 #ifdef CONFIG_USB_EHCI_EXYNOS
 int board_usb_vbus_init(void)
 {
@@ -97,6 +89,20 @@ static void  board_enable_audio_codec(void)
 }
 #endif
 
+struct cros_ec_dev *board_get_cros_ec_dev(void)
+{
+       return local.cros_ec_dev;
+}
+
+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;
+}
+
 int board_init(void)
 {
        gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
@@ -112,6 +118,10 @@ int board_init(void)
 #ifdef CONFIG_EXYNOS_SPI
        spi_init();
 #endif
+
+       if (board_init_cros_ec_devices(gd->fdt_blob))
+               return -1;
+
 #ifdef CONFIG_USB_EHCI_EXYNOS
        board_usb_vbus_init();
 #endif
@@ -421,3 +431,22 @@ void exynos_set_dp_phy(unsigned int onoff)
        set_dp_phy_ctrl(onoff);
 }
 #endif
+
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+       stdio_print_current_devices();
+
+       if (local.cros_ec_err) {
+               /* Force console on */
+               gd->flags &= ~GD_FLG_SILENT;
+
+               printf("cros-ec communications failure %d\n",
+                      local.cros_ec_err);
+               puts("\nPlease reset with Power+Refresh\n\n");
+               panic("Cannot init cros-ec device");
+               return -1;
+       }
+       return 0;
+}
+#endif