hm60x/hm801: Fix blinking white screen.
[maemo-rb.git] / firmware / export / storage.h
blob6c875bc847ecab777d8bc85e7c11a19bb78aa9e7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Alan Korr
11 * Copyright (C) 2008 by Frank Gevaerts
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #ifndef __STORAGE_H__
23 #define __STORAGE_H__
25 #include <stdbool.h>
26 #include "config.h" /* for HAVE_MULTIDRIVE or not */
27 #include "mv.h"
29 #if (CONFIG_STORAGE & STORAGE_SD)
30 #include "sd.h"
31 #endif
32 #if (CONFIG_STORAGE & STORAGE_MMC)
33 #include "mmc.h"
34 #endif
35 #if (CONFIG_STORAGE & STORAGE_ATA)
36 #include "ata.h"
37 #endif
38 #if (CONFIG_STORAGE & STORAGE_NAND)
39 #include "nand.h"
40 #endif
41 #if (CONFIG_STORAGE & STORAGE_RAMDISK)
42 #include "ramdisk.h"
43 #endif
45 struct storage_info
47 unsigned int sector_size;
48 unsigned int num_sectors;
49 char *vendor;
50 char *product;
51 char *revision;
54 #if (CONFIG_STORAGE == 0)
55 /* stubs for the plugin api */
56 static inline void stub_storage_sleep(void) {}
57 static inline void stub_storage_spin(void) {}
58 static inline void stub_storage_spindown(int timeout) { (void)timeout; }
59 #endif
61 #if defined(CONFIG_STORAGE) && !defined(CONFIG_STORAGE_MULTI)
62 /* storage_spindown, storage_sleep and storage_spin are passed as
63 * pointers, which doesn't work with argument-macros.
65 #define storage_num_drives() NUM_DRIVES
66 #if (CONFIG_STORAGE == 0) /* application */
67 #define STORAGE_FUNCTION(NAME) (stub_## NAME)
68 #define storage_spindown stub_storage_spindown
69 #define storage_sleep stub_storage_sleep
70 #define storage_spin stub_storage_spin
72 #define storage_enable(on)
73 #define storage_sleepnow()
74 #define storage_disk_is_active() 0
75 #define storage_soft_reset()
76 #define storage_init()
77 #define storage_close()
78 #elif (CONFIG_STORAGE & STORAGE_ATA)
79 #define STORAGE_FUNCTION(NAME) (ata_## NAME)
80 #define storage_spindown ata_spindown
81 #define storage_sleep ata_sleep
82 #define storage_spin ata_spin
84 #define storage_enable(on) ata_enable(on)
85 #define storage_sleepnow() ata_sleepnow()
86 #define storage_disk_is_active() ata_disk_is_active()
87 #define storage_soft_reset() ata_soft_reset()
88 #define storage_init() ata_init()
89 #define storage_close() ata_close()
90 #ifdef HAVE_STORAGE_FLUSH
91 #define storage_flush() (void)0
92 #endif
93 #define storage_last_disk_activity() ata_last_disk_activity()
94 #define storage_spinup_time() ata_spinup_time()
95 #define storage_get_identify() ata_get_identify()
97 #ifdef STORAGE_GET_INFO
98 #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
99 #endif
100 #ifdef HAVE_HOTSWAP
101 #define storage_removable(drive) ata_removable(IF_MD(drive))
102 #define storage_present(drive) ata_present(IF_MD(drive))
103 #endif
104 #elif (CONFIG_STORAGE & STORAGE_SD)
105 #define STORAGE_FUNCTION(NAME) (sd_## NAME)
106 #define storage_spindown sd_spindown
107 #define storage_sleep sd_sleep
108 #define storage_spin sd_spin
110 #define storage_enable(on) sd_enable(on)
111 #define storage_sleepnow() sd_sleepnow()
112 #define storage_disk_is_active() 0
113 #define storage_soft_reset() (void)0
114 #define storage_init() sd_init()
115 #define storage_close() sd_close()
116 #ifdef HAVE_STORAGE_FLUSH
117 #define storage_flush() (void)0
118 #endif
119 #define storage_last_disk_activity() sd_last_disk_activity()
120 #define storage_spinup_time() 0
121 #define storage_get_identify() sd_get_identify()
123 #ifdef STORAGE_GET_INFO
124 #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
125 #endif
126 #ifdef HAVE_HOTSWAP
127 #define storage_removable(drive) sd_removable(IF_MD(drive))
128 #define storage_present(drive) sd_present(IF_MD(drive))
129 #endif
130 #elif (CONFIG_STORAGE & STORAGE_MMC)
131 #define STORAGE_FUNCTION(NAME) (mmc_## NAME)
132 #define storage_spindown mmc_spindown
133 #define storage_sleep mmc_sleep
134 #define storage_spin mmc_spin
136 #define storage_enable(on) mmc_enable(on)
137 #define storage_sleepnow() mmc_sleepnow()
138 #define storage_disk_is_active() mmc_disk_is_active()
139 #define storage_soft_reset() (void)0
140 #define storage_init() mmc_init()
141 #ifdef HAVE_STORAGE_FLUSH
142 #define storage_flush() (void)0
143 #endif
144 #define storage_last_disk_activity() mmc_last_disk_activity()
145 #define storage_spinup_time() 0
146 #define storage_get_identify() mmc_get_identify()
148 #ifdef STORAGE_GET_INFO
149 #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
150 #endif
151 #ifdef HAVE_HOTSWAP
152 #define storage_removable(drive) mmc_removable(IF_MD(drive))
153 #define storage_present(drive) mmc_present(IF_MD(drive))
154 #endif
155 #elif (CONFIG_STORAGE & STORAGE_NAND)
156 #define STORAGE_FUNCTION(NAME) (nand_## NAME)
157 #define storage_spindown nand_spindown
158 #define storage_sleep nand_sleep
159 #define storage_spin nand_spin
161 #define storage_enable(on) (void)0
162 #define storage_sleepnow() nand_sleepnow()
163 #define storage_disk_is_active() 0
164 #define storage_soft_reset() (void)0
165 #define storage_init() nand_init()
166 #ifdef HAVE_STORAGE_FLUSH
167 #define storage_flush() nand_flush()
168 #endif
169 #define storage_last_disk_activity() nand_last_disk_activity()
170 #define storage_spinup_time() 0
171 #define storage_get_identify() nand_get_identify()
173 #ifdef STORAGE_GET_INFO
174 #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
175 #endif
176 #ifdef HAVE_HOTSWAP
177 #define storage_removable(drive) nand_removable(IF_MD(drive))
178 #define storage_present(drive) nand_present(IF_MD(drive))
179 #endif
180 #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
181 #define STORAGE_FUNCTION(NAME) (ramdisk_## NAME)
182 #define storage_spindown ramdisk_spindown
183 #define storage_sleep ramdisk_sleep
184 #define storage_spin ramdisk_spin
186 #define storage_enable(on) (void)0
187 #define storage_sleepnow() ramdisk_sleepnow()
188 #define storage_disk_is_active() 0
189 #define storage_soft_reset() (void)0
190 #define storage_init() ramdisk_init()
191 #ifdef HAVE_STORAGE_FLUSH
192 #define storage_flush() (void)0
193 #endif
194 #define storage_last_disk_activity() ramdisk_last_disk_activity()
195 #define storage_spinup_time() 0
196 #define storage_get_identify() ramdisk_get_identify()
198 #ifdef STORAGE_GET_INFO
199 #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
200 #endif
201 #ifdef HAVE_HOTSWAP
202 #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
203 #define storage_present(drive) ramdisk_present(IF_MD(drive))
204 #endif
205 #else
206 //#error No storage driver!
207 #endif
208 #else /* NOT CONFIG_STORAGE_MULTI and PLATFORM_NATIVE*/
210 /* Simulator and multi-driver use normal functions */
212 void storage_enable(bool on);
213 void storage_sleep(void);
214 void storage_sleepnow(void);
215 bool storage_disk_is_active(void);
216 int storage_soft_reset(void);
217 int storage_init(void) STORAGE_INIT_ATTR;
218 int storage_flush(void);
219 void storage_spin(void);
220 void storage_spindown(int seconds);
221 long storage_last_disk_activity(void);
222 int storage_spinup_time(void);
223 int storage_num_drives(void);
224 #ifdef STORAGE_GET_INFO
225 void storage_get_info(int drive, struct storage_info *info);
226 #endif
227 #ifdef HAVE_HOTSWAP
228 bool storage_removable(int drive);
229 bool storage_present(int drive);
230 #endif
232 #endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
234 int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
235 int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
236 #endif