Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Header file for UBI support for U-Boot |
| 3 | * |
| 4 | * Adaptation from kernel to U-Boot |
| 5 | * |
| 6 | * Copyright (C) 2005-2007 Samsung Electronics |
| 7 | * Kyungmin Park <kyungmin.park@samsung.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #ifndef __UBOOT_UBI_H |
| 15 | #define __UBOOT_UBI_H |
| 16 | |
| 17 | #include <common.h> |
Anton Vorontsov | 18d59c0 | 2009-09-01 20:58:03 +0400 | [diff] [blame] | 18 | #include <compiler.h> |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 19 | #include <linux/compat.h> |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 20 | #include <malloc.h> |
| 21 | #include <div64.h> |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 22 | #include <linux/math64.h> |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 23 | #include <linux/crc32.h> |
Stefan Roese | 2fc10f6 | 2009-03-19 15:35:05 +0100 | [diff] [blame] | 24 | #include <linux/types.h> |
| 25 | #include <linux/list.h> |
| 26 | #include <linux/rbtree.h> |
| 27 | #include <linux/string.h> |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 28 | #include <linux/mtd/mtd.h> |
Stefan Roese | 2fc10f6 | 2009-03-19 15:35:05 +0100 | [diff] [blame] | 29 | #include <linux/mtd/ubi.h> |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 30 | |
| 31 | #ifdef CONFIG_CMD_ONENAND |
| 32 | #include <onenand_uboot.h> |
| 33 | #endif |
| 34 | |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame^] | 35 | #include <linux/errno.h> |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 36 | |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 37 | /* configurable */ |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 38 | #if !defined(CONFIG_MTD_UBI_WL_THRESHOLD) |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 39 | #define CONFIG_MTD_UBI_WL_THRESHOLD 4096 |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 40 | #endif |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 41 | #define CONFIG_MTD_UBI_BEB_RESERVE 1 |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 42 | |
| 43 | /* debug options (Linux: drivers/mtd/ubi/Kconfig.debug) */ |
| 44 | #undef CONFIG_MTD_UBI_DEBUG |
| 45 | #undef CONFIG_MTD_UBI_DEBUG_PARANOID |
| 46 | #undef CONFIG_MTD_UBI_DEBUG_MSG |
| 47 | #undef CONFIG_MTD_UBI_DEBUG_MSG_EBA |
| 48 | #undef CONFIG_MTD_UBI_DEBUG_MSG_WL |
| 49 | #undef CONFIG_MTD_UBI_DEBUG_MSG_IO |
| 50 | #undef CONFIG_MTD_UBI_DEBUG_MSG_BLD |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 51 | |
| 52 | #undef CONFIG_MTD_UBI_BLOCK |
| 53 | |
Andrew Ruder | 42597b9 | 2014-11-05 13:31:57 -0600 | [diff] [blame] | 54 | /* ubi_init() disables returning error codes when built into the Linux |
| 55 | * kernel so that it doesn't hang the Linux kernel boot process. Since |
| 56 | * the U-Boot driver code depends on getting valid error codes from this |
| 57 | * function we just tell the UBI layer that we are building as a module |
| 58 | * (which only enables the additional error reporting). |
| 59 | */ |
| 60 | #define CONFIG_MTD_UBI_MODULE |
| 61 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 62 | #if !defined(CONFIG_MTD_UBI_BEB_LIMIT) |
| 63 | #define CONFIG_MTD_UBI_BEB_LIMIT 20 |
| 64 | #endif |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 65 | |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 66 | /* build.c */ |
| 67 | #define get_device(...) |
| 68 | #define put_device(...) |
| 69 | #define ubi_sysfs_init(...) 0 |
| 70 | #define ubi_sysfs_close(...) do { } while (0) |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 71 | |
Stefan Roese | 2fc10f6 | 2009-03-19 15:35:05 +0100 | [diff] [blame] | 72 | #ifndef __UBIFS_H__ |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 73 | #include "../drivers/mtd/ubi/ubi.h" |
Stefan Roese | 2fc10f6 | 2009-03-19 15:35:05 +0100 | [diff] [blame] | 74 | #endif |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 75 | |
| 76 | /* functions */ |
| 77 | extern int ubi_mtd_param_parse(const char *val, struct kernel_param *kp); |
| 78 | extern int ubi_init(void); |
Stefan Roese | 1b20eb8 | 2008-11-27 14:07:09 +0100 | [diff] [blame] | 79 | extern void ubi_exit(void); |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 80 | extern int ubi_part(char *part_name, const char *vid_header_offset); |
| 81 | extern int ubi_volume_write(char *volume, void *buf, size_t size); |
| 82 | extern int ubi_volume_read(char *volume, char *buf, size_t size); |
Kyungmin Park | ad7ae36 | 2008-11-19 16:32:36 +0100 | [diff] [blame] | 83 | |
| 84 | extern struct ubi_device *ubi_devices[]; |
| 85 | |
| 86 | #endif |