Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Enric Balletbo i Serra | d6b5eed | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 |
| 4 | * ISEE 2007 SL - Enric Balletbo i Serra <eballetbo@iseebcn.com> |
| 5 | * |
| 6 | * Based on common/spl/spl_nand.c |
| 7 | * Copyright (C) 2011 |
| 8 | * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> |
Enric Balletbo i Serra | d6b5eed | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 9 | */ |
| 10 | #include <common.h> |
| 11 | #include <config.h> |
| 12 | #include <spl.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <onenand_uboot.h> |
| 15 | |
Simon Glass | ee30679 | 2016-09-24 18:20:13 -0600 | [diff] [blame] | 16 | static int spl_onenand_load_image(struct spl_image_info *spl_image, |
| 17 | struct spl_boot_device *bootdev) |
Enric Balletbo i Serra | d6b5eed | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 18 | { |
| 19 | struct image_header *header; |
Marek Vasut | 02266e2 | 2016-04-29 00:44:54 +0200 | [diff] [blame] | 20 | int ret; |
Enric Balletbo i Serra | d6b5eed | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 21 | |
| 22 | debug("spl: onenand\n"); |
| 23 | |
| 24 | /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ |
| 25 | header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); |
| 26 | /* Load u-boot */ |
| 27 | onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, |
| 28 | CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header); |
Simon Glass | ee30679 | 2016-09-24 18:20:13 -0600 | [diff] [blame] | 29 | ret = spl_parse_image_header(spl_image, header); |
Marek Vasut | 02266e2 | 2016-04-29 00:44:54 +0200 | [diff] [blame] | 30 | if (ret) |
| 31 | return ret; |
Enric Balletbo i Serra | d6b5eed | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 32 | onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, |
Simon Glass | ee30679 | 2016-09-24 18:20:13 -0600 | [diff] [blame] | 33 | spl_image->size, (void *)spl_image->load_addr); |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 34 | |
| 35 | return 0; |
Enric Balletbo i Serra | d6b5eed | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 36 | } |
Simon Glass | 383aa47 | 2016-09-24 18:20:03 -0600 | [diff] [blame] | 37 | /* Use priorty 1 so that Ubi can override this */ |
Simon Glass | 4fc1f25 | 2016-11-30 15:30:50 -0700 | [diff] [blame] | 38 | SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND, |
| 39 | spl_onenand_load_image); |