mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 13:45:10 -05:00
sd-as3525v2: add card hotswap to sd_thread
Clip+: add (disabled) configuration for µSD slot git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25194 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
72e0bf3381
commit
ba68f2dedd
2 changed files with 56 additions and 0 deletions
|
|
@ -9,6 +9,14 @@
|
||||||
#define FIRMWARE_OFFSET_FILE_DATA 8
|
#define FIRMWARE_OFFSET_FILE_DATA 8
|
||||||
#define FIRMWARE_OFFSET_FILE_CRC 0
|
#define FIRMWARE_OFFSET_FILE_CRC 0
|
||||||
|
|
||||||
|
#if 0 /* TODO */
|
||||||
|
#ifndef BOOTLOADER
|
||||||
|
#define HAVE_MULTIDRIVE
|
||||||
|
#define NUM_DRIVES 2
|
||||||
|
#define HAVE_HOTSWAP
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0 /* disabled since there is no driver (yet) */
|
#if 0 /* disabled since there is no driver (yet) */
|
||||||
|
|
||||||
#define HW_SAMPR_CAPS (SAMPR_CAP_44)
|
#define HW_SAMPR_CAPS (SAMPR_CAP_44)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@
|
||||||
#include "ata_idle_notify.h"
|
#include "ata_idle_notify.h"
|
||||||
#include "sd.h"
|
#include "sd.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_HOTSWAP
|
||||||
|
#include "disk.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "sysfont.h"
|
#include "sysfont.h"
|
||||||
|
|
@ -484,6 +488,50 @@ static void sd_thread(void)
|
||||||
|
|
||||||
switch ( ev.id )
|
switch ( ev.id )
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_HOTSWAP
|
||||||
|
case SYS_HOTSWAP_INSERTED:
|
||||||
|
case SYS_HOTSWAP_EXTRACTED:
|
||||||
|
{
|
||||||
|
int microsd_init = 1;
|
||||||
|
fat_lock(); /* lock-out FAT activity first -
|
||||||
|
prevent deadlocking via disk_mount that
|
||||||
|
would cause a reverse-order attempt with
|
||||||
|
another thread */
|
||||||
|
mutex_lock(&sd_mtx); /* lock-out card activity - direct calls
|
||||||
|
into driver that bypass the fat cache */
|
||||||
|
|
||||||
|
/* We now have exclusive control of fat cache and ata */
|
||||||
|
|
||||||
|
disk_unmount(SD_SLOT_AS3525); /* release "by force", ensure file
|
||||||
|
descriptors aren't leaked and any busy
|
||||||
|
ones are invalid if mounting */
|
||||||
|
/* Force card init for new card, re-init for re-inserted one or
|
||||||
|
* clear if the last attempt to init failed with an error. */
|
||||||
|
card_info[SD_SLOT_AS3525].initialized = 0;
|
||||||
|
|
||||||
|
if (ev.id == SYS_HOTSWAP_INSERTED)
|
||||||
|
{
|
||||||
|
sd_enable(true);
|
||||||
|
microsd_init = sd_init_card(SD_SLOT_AS3525);
|
||||||
|
if (microsd_init < 0) /* initialisation failed */
|
||||||
|
panicf("microSD init failed : %d", microsd_init);
|
||||||
|
|
||||||
|
microsd_init = disk_mount(SD_SLOT_AS3525); /* 0 if fail */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mount succeeded, or this was an EXTRACTED event,
|
||||||
|
* in both cases notify the system about the changed filesystems
|
||||||
|
*/
|
||||||
|
if (microsd_init)
|
||||||
|
queue_broadcast(SYS_FS_CHANGED, 0);
|
||||||
|
/* Access is now safe */
|
||||||
|
mutex_unlock(&sd_mtx);
|
||||||
|
fat_unlock();
|
||||||
|
sd_enable(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case SYS_TIMEOUT:
|
case SYS_TIMEOUT:
|
||||||
if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ)))
|
if (TIME_BEFORE(current_tick, last_disk_activity+(3*HZ)))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue