blob: 93cbf47e8228ee7f8aa01b98c7fef5d682e23796 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Enric Balletbo i Serra60009922013-02-07 23:14:48 +00002/*
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 Serra60009922013-02-07 23:14:48 +00009 */
10#include <common.h>
11#include <config.h>
Simon Glass4d72caa2020-05-10 11:40:01 -060012#include <image.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060013#include <log.h>
Enric Balletbo i Serra60009922013-02-07 23:14:48 +000014#include <spl.h>
15#include <asm/io.h>
16#include <onenand_uboot.h>
17
Simon Glass2a2ee2a2016-09-24 18:20:13 -060018static int spl_onenand_load_image(struct spl_image_info *spl_image,
19 struct spl_boot_device *bootdev)
Enric Balletbo i Serra60009922013-02-07 23:14:48 +000020{
21 struct image_header *header;
Marek Vasut7e0f2262016-04-29 00:44:54 +020022 int ret;
Enric Balletbo i Serra60009922013-02-07 23:14:48 +000023
24 debug("spl: onenand\n");
25
Marek Vasut04ce5422018-08-14 11:27:02 +020026 header = spl_get_load_buffer(0, CONFIG_SYS_ONENAND_PAGE_SIZE);
Enric Balletbo i Serra60009922013-02-07 23:14:48 +000027 /* Load u-boot */
28 onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
29 CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
Simon Glass2a2ee2a2016-09-24 18:20:13 -060030 ret = spl_parse_image_header(spl_image, header);
Marek Vasut7e0f2262016-04-29 00:44:54 +020031 if (ret)
32 return ret;
Enric Balletbo i Serra60009922013-02-07 23:14:48 +000033 onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
Simon Glass2a2ee2a2016-09-24 18:20:13 -060034 spl_image->size, (void *)spl_image->load_addr);
Nikita Kiryanov36afd452015-11-08 17:11:49 +020035
36 return 0;
Enric Balletbo i Serra60009922013-02-07 23:14:48 +000037}
Simon Glassafa6e6c2016-09-24 18:20:03 -060038/* Use priorty 1 so that Ubi can override this */
Simon Glassebc4ef62016-11-30 15:30:50 -070039SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND,
40 spl_onenand_load_image);