blob: 04791df69bb0e76980b3e767c43c55e40e2d7045 [file] [log] [blame]
Kyungmin Park79fe6832008-01-15 08:59:44 +09001/*
2 * drivers/mtd/onenand/onenand_uboot.c
3 *
4 * Copyright (C) 2005-2008 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12/*
13 * OneNAND initialization at U-Boot
14 */
15
16#include <common.h>
Simon Glass1ab16922022-07-31 12:28:48 -060017#include <display_options.h>
Mike Frysinger11d1a092012-04-09 13:39:55 +000018#include <linux/compat.h>
Kyungmin Park79fe6832008-01-15 08:59:44 +090019#include <linux/mtd/mtd.h>
20#include <linux/mtd/onenand.h>
21
22struct mtd_info onenand_mtd;
23struct onenand_chip onenand_chip;
Stefan Roese4157c632009-04-24 15:59:35 +020024static __attribute__((unused)) char dev_name[] = "onenand0";
Kyungmin Park79fe6832008-01-15 08:59:44 +090025
26void onenand_init(void)
27{
Ladislav Michl11732712016-07-12 20:28:20 +020028 int err = 0;
Kyungmin Park79fe6832008-01-15 08:59:44 +090029 memset(&onenand_mtd, 0, sizeof(struct mtd_info));
30 memset(&onenand_chip, 0, sizeof(struct onenand_chip));
31
Kyungmin Park79fe6832008-01-15 08:59:44 +090032 onenand_mtd.priv = &onenand_chip;
33
Kyungmin Parkdc7a79c2008-11-04 09:24:07 +090034#ifdef CONFIG_USE_ONENAND_BOARD_INIT
Ladislav Michl11732712016-07-12 20:28:20 +020035 /* It's used for some board init required */
36 err = onenand_board_init(&onenand_mtd);
Kyungmin Parkdc7a79c2008-11-04 09:24:07 +090037#else
Tom Rini6a5dccc2022-11-16 13:10:41 -050038 onenand_chip.base = (void *) CFG_SYS_ONENAND_BASE;
Kyungmin Parkdc7a79c2008-11-04 09:24:07 +090039#endif
40
Ladislav Michl11732712016-07-12 20:28:20 +020041 if (!err && !(onenand_scan(&onenand_mtd, 1))) {
Kyungmin Park79fe6832008-01-15 08:59:44 +090042
Ladislav Michl11732712016-07-12 20:28:20 +020043 if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND)
44 puts("Flex-");
45 puts("OneNAND: ");
Stefan Roese4157c632009-04-24 15:59:35 +020046
Miquel Raynal2e35dbb2019-10-03 19:50:05 +020047#ifdef CONFIG_MTD
Ladislav Michl11732712016-07-12 20:28:20 +020048 /*
49 * Add MTD device so that we can reference it later
50 * via the mtdcore infrastructure (e.g. ubi).
51 */
52 onenand_mtd.name = dev_name;
53 add_mtd_device(&onenand_mtd);
Stefan Roese4157c632009-04-24 15:59:35 +020054#endif
Ladislav Michl11732712016-07-12 20:28:20 +020055 }
56 print_size(onenand_chip.chipsize, "\n");
Kyungmin Park79fe6832008-01-15 08:59:44 +090057}