1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
26 #include "config.h" /* for HAVE_MULTIVOLUME or not */
29 #if (CONFIG_STORAGE & STORAGE_SD)
32 #if (CONFIG_STORAGE & STORAGE_MMC)
35 #if (CONFIG_STORAGE & STORAGE_ATA)
38 #if (CONFIG_STORAGE & STORAGE_NAND)
44 unsigned int sector_size
;
45 unsigned int num_sectors
;
51 void storage_spindown(int seconds
);
53 static inline void storage_enable(bool on
)
55 #if (CONFIG_STORAGE & STORAGE_ATA)
57 #elif (CONFIG_STORAGE & STORAGE_SD)
59 #elif (CONFIG_STORAGE & STORAGE_MMC)
65 static inline void storage_sleep(void)
67 #if (CONFIG_STORAGE & STORAGE_ATA)
71 static inline void storage_sleepnow(void)
73 #if (CONFIG_STORAGE & STORAGE_ATA)
77 static inline bool storage_disk_is_active(void)
79 #if (CONFIG_STORAGE & STORAGE_ATA)
80 return ata_disk_is_active();
81 #elif (CONFIG_STORAGE & STORAGE_MMC)
82 return mmc_disk_is_active();
87 static inline int storage_hard_reset(void)
89 #if (CONFIG_STORAGE & STORAGE_ATA)
90 return ata_hard_reset();
95 static inline int storage_soft_reset(void)
97 #if (CONFIG_STORAGE & STORAGE_ATA)
98 return ata_soft_reset();
103 static inline int storage_init(void)
106 #if (CONFIG_STORAGE & STORAGE_ATA)
108 #elif (CONFIG_STORAGE & STORAGE_SD)
110 #elif (CONFIG_STORAGE & STORAGE_NAND)
112 #elif (CONFIG_STORAGE & STORAGE_MMC)
115 #error No storage driver!
121 static inline void storage_close(void)
123 #if (CONFIG_STORAGE & STORAGE_ATA)
127 static inline int storage_read_sectors(IF_MV2(int drive
,) unsigned long start
, int count
, void* buf
)
129 #if (CONFIG_STORAGE & STORAGE_ATA)
130 return ata_read_sectors(IF_MV2(drive
,) start
, count
, buf
);
131 #elif (CONFIG_STORAGE & STORAGE_SD)
132 return sd_read_sectors(IF_MV2(drive
,) start
, count
, buf
);
133 #elif (CONFIG_STORAGE & STORAGE_NAND)
134 return nand_read_sectors(IF_MV2(drive
,) start
, count
, buf
);
135 #elif (CONFIG_STORAGE & STORAGE_MMC)
136 return mmc_read_sectors(IF_MV2(drive
,) start
, count
, buf
);
138 #error No storage driver!
141 static inline int storage_write_sectors(IF_MV2(int drive
,) unsigned long start
, int count
, const void* buf
)
143 #if (CONFIG_STORAGE & STORAGE_ATA)
144 return ata_write_sectors(IF_MV2(drive
,) start
, count
, buf
);
145 #elif (CONFIG_STORAGE & STORAGE_SD)
146 return sd_write_sectors(IF_MV2(drive
,) start
, count
, buf
);
147 #elif (CONFIG_STORAGE & STORAGE_NAND)
148 return nand_write_sectors(IF_MV2(drive
,) start
, count
, buf
);
149 #elif (CONFIG_STORAGE & STORAGE_MMC)
150 return mmc_write_sectors(IF_MV2(drive
,) start
, count
, buf
);
152 #error No storage driver!
155 static inline void storage_spin(void)
157 #if (CONFIG_STORAGE & STORAGE_ATA)
162 #if (CONFIG_LED == LED_REAL)
163 static inline void storage_set_led_enabled(bool enabled
)
165 #if (CONFIG_STORAGE & STORAGE_ATA)
166 ata_set_led_enabled(enabled
);
167 #elif (CONFIG_STORAGE & STORAGE_SD)
168 sd_set_led_enabled(enabled
);
169 #elif (CONFIG_STORAGE & STORAGE_NAND)
170 nand_set_led_enabled(enabled
);
171 #elif (CONFIG_STORAGE & STORAGE_MMC)
172 mmc_set_led_enabled(enabled
);
174 #error No storage driver!
179 static inline long storage_last_disk_activity(void)
181 #if (CONFIG_STORAGE & STORAGE_ATA)
182 return ata_last_disk_activity();
183 #elif (CONFIG_STORAGE & STORAGE_SD)
184 return sd_last_disk_activity();
185 #elif (CONFIG_STORAGE & STORAGE_NAND)
186 return nand_last_disk_activity();
187 #elif (CONFIG_STORAGE & STORAGE_MMC)
188 return mmc_last_disk_activity();
190 #error No storage driver!
194 static inline int storage_spinup_time(void)
196 #if (CONFIG_STORAGE & STORAGE_ATA)
197 return ata_spinup_time();
203 static inline void storage_get_info(IF_MV2(int drive
,) struct storage_info
*info
)
205 #if (CONFIG_STORAGE & STORAGE_ATA)
206 return ata_get_info(IF_MV2(drive
,) info
);
207 #elif (CONFIG_STORAGE & STORAGE_SD)
208 return sd_get_info(IF_MV2(drive
,) info
);
209 #elif (CONFIG_STORAGE & STORAGE_NAND)
210 return nand_get_info(IF_MV2(drive
,) info
);
211 #elif (CONFIG_STORAGE & STORAGE_MMC)
212 return mmc_get_info(IF_MV2(drive
,) info
);
214 #error No storage driver!
219 static inline bool storage_removable(IF_MV_NONVOID(int drive
))
221 #if (CONFIG_STORAGE & STORAGE_ATA)
222 return ata_removable(IF_MV(drive
));
223 #elif (CONFIG_STORAGE & STORAGE_SD)
224 return sd_removable(IF_MV(drive
));
225 #elif (CONFIG_STORAGE & STORAGE_NAND)
226 return nand_removable(IF_MV(drive
));
227 #elif (CONFIG_STORAGE & STORAGE_MMC)
228 return mmc_removable(IF_MV(drive
));
230 #error No storage driver!
234 static inline bool storage_present(IF_MV_NONVOID(int drive
))
236 #if (CONFIG_STORAGE & STORAGE_ATA)
237 return ata_present(IF_MV(drive
));
238 #elif (CONFIG_STORAGE & STORAGE_SD)
239 return sd_present(IF_MV(drive
));
240 #elif (CONFIG_STORAGE & STORAGE_NAND)
241 return nand_present(IF_MV(drive
));
242 #elif (CONFIG_STORAGE & STORAGE_MMC)
243 return mmc_present(IF_MV(drive
));
245 #error No storage driver!