From bf3e50b89bccab5c64f23c1e54d3bbeb0994f7b2 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Thu, 3 Jun 2010 13:55:42 +0000 Subject: sd-as3525v1: do not disable peripheral clocks in sd_enable() (forward port of r26481 + cosmetics) This lead to freezes under various conditons (bug report: FS#11267) Battery life is almost not (if at all) affected: - between 4 and 8 minutes less runtime for fuzev1 - 9 minutes less runtime for c200v2 (2 minutes difference on a 2 hours run) Additional verifications of the runtime (including on other models) wouldn't hurt git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26512 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/sd-as3525.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c index 1f935a426e..ec6065630b 100644 --- a/firmware/target/arm/as3525/sd-as3525.c +++ b/firmware/target/arm/as3525/sd-as3525.c @@ -876,15 +876,12 @@ void sd_enable(bool on) if (sd_enabled == on) return; /* nothing to do */ + + sd_enabled = on; + if(on) { - /* Enable both NAF_CLOCK & IDE clk for internal SD */ - CGU_PERI |= CGU_NAF_CLOCK_ENABLE; - CGU_IDE |= (1<<6); /* enable non AHB interface*/ -#ifdef HAVE_MULTIDRIVE - /* Enable MCI clk for uSD */ - CGU_PERI |= CGU_MCI_CLOCK_ENABLE; -#ifdef HAVE_BUTTON_LIGHT +#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE) /* buttonlight AMSes need a bit of special handling for the buttonlight * here due to the dual mapping of GPIOD and XPD */ CCU_IO |= (1<<2); /* XPD is SD-MCI interface (b3:2 = 01) */ @@ -892,9 +889,7 @@ void sd_enable(bool on) GPIOD_DIR &= ~(1<<7); else _buttonlight_off(); -#endif /* HAVE_BUTTON_LIGHT */ -#endif /* HAVE_MULTIDRIVE */ - sd_enabled = true; +#endif #if defined(HAVE_HOTSWAP) && defined (HAVE_ADJUSTABLE_CPU_VOLTAGE) if(card_detect_target()) /* If SD card present Boost cpu for voltage */ @@ -914,21 +909,11 @@ void sd_enable(bool on) } #endif /* defined(HAVE_HOTSWAP) && defined (HAVE_ADJUSTABLE_CPU_VOLTAGE) */ - sd_enabled = false; - -#ifdef HAVE_MULTIDRIVE -#ifdef HAVE_BUTTON_LIGHT +#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE) CCU_IO &= ~(1<<2); /* XPD is general purpose IO (b3:2 = 00) */ if (buttonlight_is_on) _buttonlight_on(); -#endif /* HAVE_BUTTON_LIGHT */ - /* Disable MCI clk for uSD */ - CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE; -#endif /* HAVE_MULTIDRIVE */ - - /* Disable both NAF_CLOCK & IDE clk for internal SD */ - CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; - CGU_IDE &= ~(1<<6); /* disable non AHB interface*/ +#endif } } -- cgit v1.2.3