blob: f6f65286c21670c887b4aa27e69b1da7efe6d8dc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Enric Balletbo i Serrad6b5eed2013-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 Serrad6b5eed2013-02-07 23:14:48 +00009 */
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000010#include <config.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060011#include <image.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000013#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{
Simon Glassbb7d3bb2022-09-06 20:26:52 -060020 struct legacy_img_hdr *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
Marek Vasut1dda46f2018-08-14 11:27:02 +020025 header = spl_get_load_buffer(0, CONFIG_SYS_ONENAND_PAGE_SIZE);
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000026 /* Load u-boot */
27 onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
28 CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
Pali Rohárdda8f882022-01-14 14:31:38 +010029 ret = spl_parse_image_header(spl_image, bootdev, header);
Marek Vasut02266e22016-04-29 00:44:54 +020030 if (ret)
31 return ret;
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000032 onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
Simon Glassee306792016-09-24 18:20:13 -060033 spl_image->size, (void *)spl_image->load_addr);
Nikita Kiryanov33eefe42015-11-08 17:11:49 +020034
35 return 0;
Enric Balletbo i Serrad6b5eed2013-02-07 23:14:48 +000036}
Simon Glass383aa472016-09-24 18:20:03 -060037/* Use priorty 1 so that Ubi can override this */
Simon Glass4fc1f252016-11-30 15:30:50 -070038SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND,
39 spl_onenand_load_image);