2 * Header file for UBI support for U-Boot
4 * Adaptation from kernel to U-Boot
6 * Copyright (C) 2005-2007 Samsung Electronics
7 * Kyungmin Park <kyungmin.park@samsung.com>
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.
21 #include <linux/crc32.h>
22 #include <linux/types.h>
23 #include <linux/list.h>
24 #include <linux/rbtree.h>
25 #include <linux/string.h>
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/ubi.h>
29 #ifdef CONFIG_CMD_ONENAND
30 #include <onenand_uboot.h>
33 #include <asm/errno.h>
35 #define DPRINTK(format, args...) \
37 printf("%s[%d]: " format "\n", __func__, __LINE__, ##args); \
41 #define CONFIG_MTD_UBI_WL_THRESHOLD 4096
42 #define CONFIG_MTD_UBI_BEB_RESERVE 1
43 #define UBI_IO_DEBUG 0
45 /* debug options (Linux: drivers/mtd/ubi/Kconfig.debug) */
46 #undef CONFIG_MTD_UBI_DEBUG
47 #undef CONFIG_MTD_UBI_DEBUG_PARANOID
48 #undef CONFIG_MTD_UBI_DEBUG_MSG
49 #undef CONFIG_MTD_UBI_DEBUG_MSG_EBA
50 #undef CONFIG_MTD_UBI_DEBUG_MSG_WL
51 #undef CONFIG_MTD_UBI_DEBUG_MSG_IO
52 #undef CONFIG_MTD_UBI_DEBUG_MSG_BLD
53 #define CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
56 #define get_device(...)
57 #define put_device(...)
58 #define ubi_sysfs_init(...) 0
59 #define ubi_sysfs_close(...) do { } while (0)
60 static inline int is_power_of_2(unsigned long n)
62 return (n != 0 && ((n & (n - 1)) == 0));
70 #define alloc_chrdev_region(...) 0
71 #define unregister_chrdev_region(...)
73 #define class_create(...) __builtin_return_address(0)
74 #define class_create_file(...) 0
75 #define class_remove_file(...)
76 #define class_destroy(...)
77 #define misc_register(...) 0
78 #define misc_deregister(...)
81 #define device_register(...) 0
82 #define volume_sysfs_init(...) 0
83 #define volume_sysfs_close(...) do { } while (0)
90 #define init_waitqueue_head(...) do { } while (0)
91 #define wait_event_interruptible(...) 0
92 #define wake_up_interruptible(...) do { } while (0)
93 #define print_hex_dump(...) do { } while (0)
94 #define dump_stack(...) do { } while (0)
97 #define task_pid_nr(x) 0
98 #define set_freezable(...) do { } while (0)
99 #define try_to_freeze(...) 0
100 #define set_current_state(...) do { } while (0)
101 #define kthread_should_stop(...) 0
102 #define schedule() do { } while (0)
105 static inline unsigned long copy_from_user(void *dest, const void *src,
108 memcpy((void *)dest, (void *)src, count);
113 typedef int spinlock_t;
114 typedef int wait_queue_head_t;
115 #define spin_lock_init(...)
116 #define spin_lock(...)
117 #define spin_lock_irqsave(...)
118 #define spin_lock_irq(...)
119 #define spin_unlock(...)
120 #define spin_unlock_irqrestore(...)
121 #define spin_unlock_irq(...)
123 typedef enum { false = 0, true = 1 } bool;
125 #define mutex_init(...)
126 #define mutex_lock(...)
127 #define mutex_unlock(...)
129 #define init_rwsem(...) do { } while (0)
130 #define down_read(...) do { } while (0)
131 #define down_write(...) do { } while (0)
132 #define down_write_trylock(...) 1
133 #define up_read(...) do { } while (0)
134 #define up_write(...) do { } while (0)
136 struct kmem_cache { int i; };
137 #define kmem_cache_create(...) 1
138 #define kmem_cache_alloc(obj, gfp) malloc(sizeof(struct ubi_wl_entry))
139 #define kmem_cache_free(obj, size) free(size)
140 #define kmem_cache_destroy(...)
142 #define cond_resched() do { } while (0)
143 #define yield() do { } while (0)
159 #define kthread_create(...) __builtin_return_address(0)
160 #define kthread_stop(...) do { } while (0)
161 #define wake_up_process(...) do { } while (0)
163 #define BUS_ID_SIZE 20
165 struct rw_semaphore { int i; };
167 struct device *parent;
169 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
170 dev_t devt; /* dev_t, creates the sysfs "dev" */
171 void (*release)(struct device *dev);
172 void *driver_data; /* data private to the driver */
174 struct mutex { int i; };
175 struct kernel_param { int i; };
181 #define cdev_init(...) do { } while (0)
182 #define cdev_add(...) 0
183 #define cdev_del(...) do { } while (0)
185 #define MAX_ERRNO 4095
186 #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
188 static inline void *ERR_PTR(long error)
190 return (void *) error;
193 static inline long PTR_ERR(const void *ptr)
198 static inline long IS_ERR(const void *ptr)
200 return IS_ERR_VALUE((unsigned long)ptr);
203 static inline long IS_ERR_OR_NULL(const void *ptr)
205 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
208 /* Force a compilation error if condition is true */
209 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
212 #define THIS_MODULE 0
213 #define try_module_get(...) 1
214 #define module_put(...) do { } while (0)
215 #define module_init(...)
216 #define module_exit(...)
217 #define EXPORT_SYMBOL(...)
218 #define EXPORT_SYMBOL_GPL(...)
219 #define module_param_call(...)
220 #define module_param(...)
221 #define MODULE_PARM_DESC(...)
222 #define MODULE_VERSION(...)
223 #define MODULE_DESCRIPTION(...)
224 #define MODULE_AUTHOR(...)
225 #define MODULE_LICENSE(...)
227 #define might_sleep_if(...)
228 #define trace_gpio_value(...)
229 #define trace_gpio_direction(...)
231 #define printk printf
233 #define pr_fmt(fmt) fmt
235 #define pr_emerg(fmt, ...) \
236 printk(pr_fmt(fmt), ##__VA_ARGS__)
237 #define pr_alert(fmt, ...) \
238 printk(pr_fmt(fmt), ##__VA_ARGS__)
239 #define pr_crit(fmt, ...) \
240 printk(pr_fmt(fmt), ##__VA_ARGS__)
241 #define pr_err(fmt, ...) \
242 printk(pr_fmt(fmt), ##__VA_ARGS__)
243 #define pr_warning(fmt, ...) \
244 printk(pr_fmt(fmt), ##__VA_ARGS__)
245 #define pr_warn pr_warning
246 #define pr_notice(fmt, ...) \
247 printk(pr_fmt(fmt), ##__VA_ARGS__)
248 #define pr_info(fmt, ...) \
249 printk(pr_fmt(fmt), ##__VA_ARGS__)
250 #define pr_cont(fmt, ...) \
251 printk(fmt, ##__VA_ARGS__)
253 #define pr_debug(fmt, ...) \
254 printk(fmt, ##__VA_ARGS__)
256 #define pr_debug(fmt, ...)
260 #define __WARN() printf("warning @ %s: %d\n", __func__, __LINE__)
262 #ifndef __WARN_printf
263 #define __WARN_printf(arg...) do { printf(arg); __WARN(); } while (0)
266 #define WARN_ON(condition) ({ \
267 int __ret_warn_on = !!(condition); \
268 if (unlikely(__ret_warn_on)) \
270 unlikely(__ret_warn_on); \
275 #define WARN(condition, format...) ({ \
276 int __ret_warn_on = !!(condition); \
277 if (unlikely(__ret_warn_on)) \
278 __WARN_printf(format); \
279 unlikely(__ret_warn_on); \
284 #include "../drivers/mtd/ubi/ubi.h"
288 extern int ubi_mtd_param_parse(const char *val, struct kernel_param *kp);
289 extern int ubi_init(void);
290 extern void ubi_exit(void);
292 extern struct ubi_device *ubi_devices[];