Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 1 | /* |
| 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> |
Mike Frysinger | 11d1a09 | 2012-04-09 13:39:55 +0000 | [diff] [blame] | 17 | #include <linux/compat.h> |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 18 | #include <linux/mtd/mtd.h> |
| 19 | #include <linux/mtd/onenand.h> |
| 20 | |
| 21 | struct mtd_info onenand_mtd; |
| 22 | struct onenand_chip onenand_chip; |
Stefan Roese | 4157c63 | 2009-04-24 15:59:35 +0200 | [diff] [blame] | 23 | static __attribute__((unused)) char dev_name[] = "onenand0"; |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 24 | |
| 25 | void onenand_init(void) |
| 26 | { |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 27 | int err = 0; |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 28 | memset(&onenand_mtd, 0, sizeof(struct mtd_info)); |
| 29 | memset(&onenand_chip, 0, sizeof(struct onenand_chip)); |
| 30 | |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 31 | onenand_mtd.priv = &onenand_chip; |
| 32 | |
Kyungmin Park | dc7a79c | 2008-11-04 09:24:07 +0900 | [diff] [blame] | 33 | #ifdef CONFIG_USE_ONENAND_BOARD_INIT |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 34 | /* It's used for some board init required */ |
| 35 | err = onenand_board_init(&onenand_mtd); |
Kyungmin Park | dc7a79c | 2008-11-04 09:24:07 +0900 | [diff] [blame] | 36 | #else |
| 37 | onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE; |
| 38 | #endif |
| 39 | |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 40 | if (!err && !(onenand_scan(&onenand_mtd, 1))) { |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 41 | |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 42 | if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND) |
| 43 | puts("Flex-"); |
| 44 | puts("OneNAND: "); |
Stefan Roese | 4157c63 | 2009-04-24 15:59:35 +0200 | [diff] [blame] | 45 | |
Stefan Roese | 22ce6f9 | 2009-05-12 14:31:18 +0200 | [diff] [blame] | 46 | #ifdef CONFIG_MTD_DEVICE |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 47 | /* |
| 48 | * Add MTD device so that we can reference it later |
| 49 | * via the mtdcore infrastructure (e.g. ubi). |
| 50 | */ |
| 51 | onenand_mtd.name = dev_name; |
| 52 | add_mtd_device(&onenand_mtd); |
Stefan Roese | 4157c63 | 2009-04-24 15:59:35 +0200 | [diff] [blame] | 53 | #endif |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 54 | } |
| 55 | print_size(onenand_chip.chipsize, "\n"); |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 56 | } |