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> |
Simon Glass | 1ab1692 | 2022-07-31 12:28:48 -0600 | [diff] [blame] | 17 | #include <display_options.h> |
Mike Frysinger | 11d1a09 | 2012-04-09 13:39:55 +0000 | [diff] [blame] | 18 | #include <linux/compat.h> |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 19 | #include <linux/mtd/mtd.h> |
| 20 | #include <linux/mtd/onenand.h> |
| 21 | |
| 22 | struct mtd_info onenand_mtd; |
| 23 | struct onenand_chip onenand_chip; |
Stefan Roese | 4157c63 | 2009-04-24 15:59:35 +0200 | [diff] [blame] | 24 | static __attribute__((unused)) char dev_name[] = "onenand0"; |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 25 | |
| 26 | void onenand_init(void) |
| 27 | { |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 28 | int err = 0; |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 29 | memset(&onenand_mtd, 0, sizeof(struct mtd_info)); |
| 30 | memset(&onenand_chip, 0, sizeof(struct onenand_chip)); |
| 31 | |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 32 | onenand_mtd.priv = &onenand_chip; |
| 33 | |
Kyungmin Park | dc7a79c | 2008-11-04 09:24:07 +0900 | [diff] [blame] | 34 | #ifdef CONFIG_USE_ONENAND_BOARD_INIT |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 35 | /* It's used for some board init required */ |
| 36 | err = onenand_board_init(&onenand_mtd); |
Kyungmin Park | dc7a79c | 2008-11-04 09:24:07 +0900 | [diff] [blame] | 37 | #else |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 38 | onenand_chip.base = (void *) CFG_SYS_ONENAND_BASE; |
Kyungmin Park | dc7a79c | 2008-11-04 09:24:07 +0900 | [diff] [blame] | 39 | #endif |
| 40 | |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 41 | if (!err && !(onenand_scan(&onenand_mtd, 1))) { |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 42 | |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 43 | if (onenand_chip.device_id & DEVICE_IS_FLEXONENAND) |
| 44 | puts("Flex-"); |
| 45 | puts("OneNAND: "); |
Stefan Roese | 4157c63 | 2009-04-24 15:59:35 +0200 | [diff] [blame] | 46 | |
Miquel Raynal | 2e35dbb | 2019-10-03 19:50:05 +0200 | [diff] [blame] | 47 | #ifdef CONFIG_MTD |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 48 | /* |
| 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 Roese | 4157c63 | 2009-04-24 15:59:35 +0200 | [diff] [blame] | 54 | #endif |
Ladislav Michl | 1173271 | 2016-07-12 20:28:20 +0200 | [diff] [blame] | 55 | } |
| 56 | print_size(onenand_chip.chipsize, "\n"); |
Kyungmin Park | 79fe683 | 2008-01-15 08:59:44 +0900 | [diff] [blame] | 57 | } |