From a22ab3464937aa29dca7fbb6cf27c825b45fd37c Mon Sep 17 00:00:00 2001 From: Jack Halpin Date: Tue, 1 Dec 2009 18:22:25 +0000 Subject: Sansa AMS: Reorganize sd_enable() and add/change comments. No real functional changes. Enabling/disabling of the NAF and IDE clocks is now grouped together as both are related to the internal SD. Sequence for disabling SD now mirrors the enable sequence. Comments added to make it easier to follow the configuration change for XPD from gpio to mci-sd and back. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23808 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/ata_sd_as3525.c | 38 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'firmware/target/arm/as3525/ata_sd_as3525.c') diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index f13f2f868d..bbf47a0960 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c @@ -816,8 +816,6 @@ long sd_last_disk_activity(void) void sd_enable(bool on) { - /* buttonlight AMSes need a bit of special handling for the buttonlight here - * due to the dual mapping of GPIOD and XPD */ #if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE) extern int buttonlight_is_on; #endif @@ -830,19 +828,23 @@ void sd_enable(bool on) return; /* nothing to do */ if(on) { + /* Enable both NAF_CLOCK & IDE clk for internal SD */ CGU_PERI |= CGU_NAF_CLOCK_ENABLE; + CGU_IDE |= ((1<<7) /* IDE AHB interface enable */ + | (1<<6)); /* IDE interface enable */ #ifdef HAVE_MULTIDRIVE + /* Enable MCI clk for uSD */ CGU_PERI |= CGU_MCI_CLOCK_ENABLE; #ifdef HAVE_BUTTON_LIGHT - CCU_IO |= (1<<2); + /* 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) */ if (buttonlight_is_on) GPIOD_DIR &= ~(1<<7); else _buttonlight_off(); #endif /* HAVE_BUTTON_LIGHT */ #endif /* HAVE_MULTIDRIVE */ - CGU_IDE |= (1<<7) /* AHB interface enable */ | - (1<<6) /* interface enable */; sd_enabled = true; #ifdef HAVE_HOTSWAP @@ -855,25 +857,29 @@ void sd_enable(bool on) } else { - CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; +#ifdef HAVE_HOTSWAP + if(cpu_boosted) + { + cpu_boost(false); + cpu_boosted = false; + } +#endif + sd_enabled = false; + #ifdef HAVE_MULTIDRIVE #ifdef HAVE_BUTTON_LIGHT - CCU_IO &= ~(1<<2); + 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 */ - CGU_IDE &= ~((1<<7)|(1<<6)); - sd_enabled = false; -#ifdef HAVE_HOTSWAP - if(cpu_boosted) - { - cpu_boost(false); - cpu_boosted = false; - } -#endif + /* Disable both NAF_CLOCK & IDE clk for internal SD */ + CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; + CGU_IDE &= ~((1<<7) /* IDE AHB interface disable */ + | (1<<6)); /* IDE interface disable */ } } -- cgit v1.2.3