]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - common/spl/spl_nand.c
compiler*.h: sync include/linux/compiler*.h with Linux 4.5-rc6
[karo-tx-uboot.git] / common / spl / spl_nand.c
index 61de5a4f05fe3a67562bb35c595c03cd2f4c509f..f58c21a7d646a440add27647608fa0be6df123ae 100644 (file)
@@ -2,23 +2,7 @@
  * Copyright (C) 2011
  * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
  *
- * 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 <config.h>
 #include <asm/io.h>
 #include <nand.h>
 
-void spl_nand_load_image(void)
+#if defined(CONFIG_SPL_NAND_RAW_ONLY)
+int spl_nand_load_image(void)
+{
+       int ret;
+
+       nand_init();
+
+       ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+                           CONFIG_SYS_NAND_U_BOOT_SIZE,
+                           (void *)CONFIG_SYS_NAND_U_BOOT_DST);
+       nand_deselect();
+       if (ret)
+               return ret;
+
+       spl_set_header_raw_uboot();
+       return 0;
+}
+#else
+int spl_nand_load_image(void)
 {
+       int ret;
        struct image_header *header;
        int *src __attribute__((unused));
        int *dst __attribute__((unused));
@@ -36,7 +39,7 @@ void spl_nand_load_image(void)
        nand_init();
 
        /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
-       header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+       header = (struct image_header *)CONFIG_SYS_TEXT_BASE;
 #ifdef CONFIG_SPL_OS_BOOT
        if (!spl_start_uboot()) {
                /*
@@ -60,41 +63,45 @@ void spl_nand_load_image(void)
 
                /* load linux */
                nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
-                       CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+                       sizeof(*header), (void *)header);
                spl_parse_image_header(header);
                if (header->ih_os == IH_OS_LINUX) {
                        /* happy - was a linux */
                        nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
                                spl_image.size, (void *)spl_image.load_addr);
                        nand_deselect();
-                       return;
+                       return 0;
                } else {
-                       puts("The Expected Linux image was not "
-                               "found. Please check your NAND "
+                       printf("The Expected Linux image was not"
+                               "found. Please check your NAND"
                                "configuration.\n");
-                       puts("Trying to start u-boot now...\n");
+                       printf("Trying to start u-boot now...\n");
                }
        }
 #endif
 #ifdef CONFIG_NAND_ENV_DST
        nand_spl_load_image(CONFIG_ENV_OFFSET,
-               CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+               sizeof(*header), (void *)header);
        spl_parse_image_header(header);
        nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
                (void *)spl_image.load_addr);
 #ifdef CONFIG_ENV_OFFSET_REDUND
        nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
-               CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+               sizeof(*header), (void *)header);
        spl_parse_image_header(header);
        nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
                (void *)spl_image.load_addr);
 #endif
 #endif
        /* Load u-boot */
-       nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-               CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
-       spl_parse_image_header(header);
-       nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-               spl_image.size, (void *)spl_image.load_addr);
+       ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+                               CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
+       if (ret == 0) {
+               spl_parse_image_header(header);
+               ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+                                       spl_image.size, (void *)spl_image.load_addr);
+       }
        nand_deselect();
+       return ret;
 }
+#endif