blob: c642016c2d2ed482a903ecf6f2ead3f119008c76 [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>
Kyungmin Park79fe6832008-01-15 08:59:44 +090017#include <linux/mtd/compat.h>
18#include <linux/mtd/mtd.h>
19#include <linux/mtd/onenand.h>
20
21struct mtd_info onenand_mtd;
22struct onenand_chip onenand_chip;
Stefan Roese4157c632009-04-24 15:59:35 +020023static __attribute__((unused)) char dev_name[] = "onenand0";
Kyungmin Park79fe6832008-01-15 08:59:44 +090024
25void onenand_init(void)
26{
27 memset(&onenand_mtd, 0, sizeof(struct mtd_info));
28 memset(&onenand_chip, 0, sizeof(struct onenand_chip));
29
Kyungmin Park79fe6832008-01-15 08:59:44 +090030 onenand_mtd.priv = &onenand_chip;
31
Kyungmin Parkdc7a79c2008-11-04 09:24:07 +090032#ifdef CONFIG_USE_ONENAND_BOARD_INIT
33 /*
34 * It's used for some board init required
35 */
36 onenand_board_init(&onenand_mtd);
37#else
38 onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE;
39#endif
40
Kyungmin Park79fe6832008-01-15 08:59:44 +090041 onenand_scan(&onenand_mtd, 1);
42
Amul Kumar Sahaed886a22009-11-06 17:15:31 +053043 if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND)
44 puts("Flex-");
Kyungmin Park79fe6832008-01-15 08:59:44 +090045 puts("OneNAND: ");
Amul Kumar Sahaed886a22009-11-06 17:15:31 +053046 print_size(onenand_chip.chipsize, "\n");
Stefan Roese4157c632009-04-24 15:59:35 +020047
Stefan Roese22ce6f92009-05-12 14:31:18 +020048#ifdef CONFIG_MTD_DEVICE
Stefan Roese4157c632009-04-24 15:59:35 +020049 /*
50 * Add MTD device so that we can reference it later
51 * via the mtdcore infrastructure (e.g. ubi).
52 */
53 onenand_mtd.name = dev_name;
54 add_mtd_device(&onenand_mtd);
55#endif
Kyungmin Park79fe6832008-01-15 08:59:44 +090056}