forked from len0rd/rockbox
(1) Early USB detection on boot, before trying to mount the partitions. Cleaner & quicker; removes the need for the extra USB check at the top of ask_resume() which caused a deadlock in screenshot mode (see patch #1110332). On Ondio, this allows to leave an MMC in the slot when booting with USB connected for instant access. (2) Ondio: Track MMC status, only ask to remove the card if required. Probe MMC status if unknown.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6488 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
32be590e6d
commit
27abc2a641
6 changed files with 64 additions and 21 deletions
16
apps/main.c
16
apps/main.c
|
@ -127,6 +127,7 @@ void init(void)
|
||||||
void init(void)
|
void init(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
bool mounted = false;
|
||||||
#if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
|
#if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
|
||||||
/* if nobody initialized ATA before, I consider this a cold start */
|
/* if nobody initialized ATA before, I consider this a cold start */
|
||||||
bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
|
bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
|
||||||
|
@ -216,8 +217,20 @@ void init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_start_monitoring();
|
usb_start_monitoring();
|
||||||
|
while (usb_detect())
|
||||||
|
{ /* enter USB mode early, before trying to mount */
|
||||||
|
if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED)
|
||||||
|
#ifdef HAVE_MMC
|
||||||
|
if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
usb_screen();
|
||||||
|
mounted = true; /* mounting done @ end of USB mode */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* FixMe: the same kind of mounting happens in usb.c, share the code. */
|
if (!mounted)
|
||||||
|
{
|
||||||
rc = disk_mount_all();
|
rc = disk_mount_all();
|
||||||
if (rc<=0)
|
if (rc<=0)
|
||||||
{
|
{
|
||||||
|
@ -233,6 +246,7 @@ void init(void)
|
||||||
usb_screen();
|
usb_screen();
|
||||||
system_reboot();
|
system_reboot();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
settings_calc_config_sector();
|
settings_calc_config_sector();
|
||||||
settings_load(SETTINGS_ALL);
|
settings_load(SETTINGS_ALL);
|
||||||
|
|
|
@ -353,7 +353,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
||||||
if (callback != NULL)
|
if (callback != NULL)
|
||||||
callback(parameter);
|
callback(parameter);
|
||||||
#ifdef HAVE_MMC
|
#ifdef HAVE_MMC
|
||||||
if (!mmc_detect() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
|
if (!mmc_touched() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
|
||||||
#endif
|
#endif
|
||||||
usb_screen();
|
usb_screen();
|
||||||
return SYS_USB_CONNECTED;
|
return SYS_USB_CONNECTED;
|
||||||
|
|
|
@ -97,6 +97,7 @@ void usb_display_info(void)
|
||||||
status_draw(true);
|
status_draw(true);
|
||||||
lcd_update();
|
lcd_update();
|
||||||
#else
|
#else
|
||||||
|
lcd_double_height(false);
|
||||||
lcd_puts(0, 0, "[USB Mode]");
|
lcd_puts(0, 0, "[USB Mode]");
|
||||||
status_set_param(false);
|
status_set_param(false);
|
||||||
status_set_audio(false);
|
status_set_audio(false);
|
||||||
|
|
|
@ -434,11 +434,6 @@ static bool ask_resume(bool ask_once)
|
||||||
lcd_double_height(false);
|
lcd_double_height(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (usb_detect()) {
|
|
||||||
default_event_handler(SYS_USB_CONNECTED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_ALARM_MOD
|
#ifdef HAVE_ALARM_MOD
|
||||||
if ( rtc_check_alarm_started(true) ) {
|
if ( rtc_check_alarm_started(true) ) {
|
||||||
rtc_enable_alarm(false);
|
rtc_enable_alarm(false);
|
||||||
|
|
|
@ -102,6 +102,12 @@ static bool delayed_write = false;
|
||||||
static unsigned char delayed_sector[SECTOR_SIZE];
|
static unsigned char delayed_sector[SECTOR_SIZE];
|
||||||
static int delayed_sector_num;
|
static int delayed_sector_num;
|
||||||
|
|
||||||
|
static enum {
|
||||||
|
MMC_UNKNOWN,
|
||||||
|
MMC_UNTOUCHED,
|
||||||
|
MMC_TOUCHED
|
||||||
|
} mmc_status = MMC_UNKNOWN;
|
||||||
|
|
||||||
static enum {
|
static enum {
|
||||||
SER_POLL_WRITE,
|
SER_POLL_WRITE,
|
||||||
SER_POLL_READ,
|
SER_POLL_READ,
|
||||||
|
@ -429,6 +435,8 @@ static int initialize_card(int card_no)
|
||||||
10000000, 100000000, 1000000000
|
10000000, 100000000, 1000000000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (card_no == 1)
|
||||||
|
mmc_status = MMC_TOUCHED;
|
||||||
/* switch to SPI mode */
|
/* switch to SPI mode */
|
||||||
send_cmd(CMD_GO_IDLE_STATE, 0, response);
|
send_cmd(CMD_GO_IDLE_STATE, 0, response);
|
||||||
if (response[0] != 0x01)
|
if (response[0] != 0x01)
|
||||||
|
@ -1046,6 +1054,27 @@ bool mmc_detect(void)
|
||||||
return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false;
|
return adc_read(ADC_MMC_SWITCH) < 0x200 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mmc_touched(void)
|
||||||
|
{
|
||||||
|
if (mmc_status == MMC_UNKNOWN) /* try to detect */
|
||||||
|
{
|
||||||
|
unsigned char response;
|
||||||
|
|
||||||
|
mutex_lock(&mmc_mutex);
|
||||||
|
mmc_select_clock(1);
|
||||||
|
setup_sci1(7); /* safe value */
|
||||||
|
and_b(~0x02, &PADRH); /* assert CS */
|
||||||
|
send_cmd(CMD_SEND_OP_COND, 0, &response);
|
||||||
|
if (response == 0xFF)
|
||||||
|
mmc_status = MMC_UNTOUCHED;
|
||||||
|
else
|
||||||
|
mmc_status = MMC_TOUCHED;
|
||||||
|
|
||||||
|
deselect_card();
|
||||||
|
}
|
||||||
|
return mmc_status == MMC_TOUCHED;
|
||||||
|
}
|
||||||
|
|
||||||
bool mmc_usb_active(int delayticks)
|
bool mmc_usb_active(int delayticks)
|
||||||
{
|
{
|
||||||
/* reading "inactive" is delayed by user-supplied monoflop value */
|
/* reading "inactive" is delayed by user-supplied monoflop value */
|
||||||
|
@ -1094,6 +1123,7 @@ static void mmc_tick(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
queue_broadcast(SYS_MMC_EXTRACTED, NULL);
|
queue_broadcast(SYS_MMC_EXTRACTED, NULL);
|
||||||
|
mmc_status = MMC_UNTOUCHED;
|
||||||
card_info[1].initialized = false;
|
card_info[1].initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1157,6 +1187,8 @@ int ata_init(void)
|
||||||
|
|
||||||
if ( !initialized )
|
if ( !initialized )
|
||||||
{
|
{
|
||||||
|
if (!last_mmc_status)
|
||||||
|
mmc_status = MMC_UNTOUCHED;
|
||||||
new_mmc_circuit = ((read_hw_mask() & MMC_CLOCK_POLARITY) != 0);
|
new_mmc_circuit = ((read_hw_mask() & MMC_CLOCK_POLARITY) != 0);
|
||||||
#ifdef HAVE_HOTSWAP
|
#ifdef HAVE_HOTSWAP
|
||||||
queue_init(&mmc_queue);
|
queue_init(&mmc_queue);
|
||||||
|
|
|
@ -44,6 +44,7 @@ bool mmc_detect(void);
|
||||||
unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
|
unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
tCardInfo *mmc_card_info(int card_no);
|
tCardInfo *mmc_card_info(int card_no);
|
||||||
|
bool mmc_touched(void);
|
||||||
bool mmc_usb_active(int delayticks);
|
bool mmc_usb_active(int delayticks);
|
||||||
#ifdef HAVE_HOTSWAP
|
#ifdef HAVE_HOTSWAP
|
||||||
void mmc_enable_monitoring(bool on);
|
void mmc_enable_monitoring(bool on);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue