Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Enric Balletbo i Serra | 6000992 | 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 | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 9 | */ |
| 10 | #include <common.h> |
| 11 | #include <config.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 13 | #include <log.h> |
Enric Balletbo i Serra | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 14 | #include <spl.h> |
| 15 | #include <asm/io.h> |
| 16 | #include <onenand_uboot.h> |
| 17 | |
Simon Glass | 2a2ee2a | 2016-09-24 18:20:13 -0600 | [diff] [blame] | 18 | static int spl_onenand_load_image(struct spl_image_info *spl_image, |
| 19 | struct spl_boot_device *bootdev) |
Enric Balletbo i Serra | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 20 | { |
| 21 | struct image_header *header; |
Marek Vasut | 7e0f226 | 2016-04-29 00:44:54 +0200 | [diff] [blame] | 22 | int ret; |
Enric Balletbo i Serra | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 23 | |
| 24 | debug("spl: onenand\n"); |
| 25 | |
Marek Vasut | 04ce542 | 2018-08-14 11:27:02 +0200 | [diff] [blame] | 26 | header = spl_get_load_buffer(0, CONFIG_SYS_ONENAND_PAGE_SIZE); |
Enric Balletbo i Serra | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 27 | /* Load u-boot */ |
| 28 | onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, |
| 29 | CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header); |
Pali Rohár | 2e0429b | 2022-01-14 14:31:38 +0100 | [diff] [blame] | 30 | ret = spl_parse_image_header(spl_image, bootdev, header); |
Marek Vasut | 7e0f226 | 2016-04-29 00:44:54 +0200 | [diff] [blame] | 31 | if (ret) |
| 32 | return ret; |
Enric Balletbo i Serra | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 33 | onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS, |
Simon Glass | 2a2ee2a | 2016-09-24 18:20:13 -0600 | [diff] [blame] | 34 | spl_image->size, (void *)spl_image->load_addr); |
Nikita Kiryanov | 36afd45 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 35 | |
| 36 | return 0; |
Enric Balletbo i Serra | 6000992 | 2013-02-07 23:14:48 +0000 | [diff] [blame] | 37 | } |
Simon Glass | afa6e6c | 2016-09-24 18:20:03 -0600 | [diff] [blame] | 38 | /* Use priorty 1 so that Ubi can override this */ |
Simon Glass | ebc4ef6 | 2016-11-30 15:30:50 -0700 | [diff] [blame] | 39 | SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND, |
| 40 | spl_onenand_load_image); |