blob: fc98e9cbe5806bbe376bb09993747dd2e540924d [file] [log] [blame]
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +00001/*
2 * Copyright (C) 2013
3 * ISEE 2007 SL - Enric Balletbo i Serra <eballetbo@iseebcn.com>
4 *
5 * Based on common/spl/spl_nand.c
6 * Copyright (C) 2011
7 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
8 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000010 */
11#include <common.h>
12#include <config.h>
13#include <spl.h>
14#include <asm/io.h>
15#include <onenand_uboot.h>
16
Simon Glassee306792016-09-24 18:20:13 -060017static int spl_onenand_load_image(struct spl_image_info *spl_image,
18 struct spl_boot_device *bootdev)
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000019{
20 struct image_header *header;
Marek Vasut02266e22016-04-29 00:44:54 +020021 int ret;
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000022
23 debug("spl: onenand\n");
24
25 /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
26 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
27 /* Load u-boot */
28 onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
29 CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
Simon Glassee306792016-09-24 18:20:13 -060030 ret = spl_parse_image_header(spl_image, header);
Marek Vasut02266e22016-04-29 00:44:54 +020031 if (ret)
32 return ret;
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000033 onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
Simon Glassee306792016-09-24 18:20:13 -060034 spl_image->size, (void *)spl_image->load_addr);
Nikita Kiryanov33eefe42015-11-08 17:11:49 +020035
36 return 0;
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000037}
Simon Glass383aa472016-09-24 18:20:03 -060038/* Use priorty 1 so that Ubi can override this */
Simon Glass4fc1f252016-11-30 15:30:50 -070039SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND,
40 spl_onenand_load_image);