summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/ata_sd_as3525.c
diff options
context:
space:
mode:
authorJack Halpin <jack.halpin@gmail.com>2009-12-01 18:22:25 +0000
committerJack Halpin <jack.halpin@gmail.com>2009-12-01 18:22:25 +0000
commita22ab3464937aa29dca7fbb6cf27c825b45fd37c (patch)
tree1023dc8e8984bbc87d13ac516926610e38b8175f /firmware/target/arm/as3525/ata_sd_as3525.c
parent2f4bce3f2cc31ccc5ba83db7dc0b86b9bc705265 (diff)
downloadrockbox-a22ab3464937aa29dca7fbb6cf27c825b45fd37c.tar.gz
rockbox-a22ab3464937aa29dca7fbb6cf27c825b45fd37c.zip
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
Diffstat (limited to 'firmware/target/arm/as3525/ata_sd_as3525.c')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c38
1 files changed, 22 insertions, 16 deletions
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)
816 816
817void sd_enable(bool on) 817void sd_enable(bool on)
818{ 818{
819 /* buttonlight AMSes need a bit of special handling for the buttonlight here
820 * due to the dual mapping of GPIOD and XPD */
821#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE) 819#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE)
822 extern int buttonlight_is_on; 820 extern int buttonlight_is_on;
823#endif 821#endif
@@ -830,19 +828,23 @@ void sd_enable(bool on)
830 return; /* nothing to do */ 828 return; /* nothing to do */
831 if(on) 829 if(on)
832 { 830 {
831 /* Enable both NAF_CLOCK & IDE clk for internal SD */
833 CGU_PERI |= CGU_NAF_CLOCK_ENABLE; 832 CGU_PERI |= CGU_NAF_CLOCK_ENABLE;
833 CGU_IDE |= ((1<<7) /* IDE AHB interface enable */
834 | (1<<6)); /* IDE interface enable */
834#ifdef HAVE_MULTIDRIVE 835#ifdef HAVE_MULTIDRIVE
836 /* Enable MCI clk for uSD */
835 CGU_PERI |= CGU_MCI_CLOCK_ENABLE; 837 CGU_PERI |= CGU_MCI_CLOCK_ENABLE;
836#ifdef HAVE_BUTTON_LIGHT 838#ifdef HAVE_BUTTON_LIGHT
837 CCU_IO |= (1<<2); 839 /* buttonlight AMSes need a bit of special handling for the buttonlight
840 * here due to the dual mapping of GPIOD and XPD */
841 CCU_IO |= (1<<2); /* XPD is SD-MCI interface (b3:2 = 01) */
838 if (buttonlight_is_on) 842 if (buttonlight_is_on)
839 GPIOD_DIR &= ~(1<<7); 843 GPIOD_DIR &= ~(1<<7);
840 else 844 else
841 _buttonlight_off(); 845 _buttonlight_off();
842#endif /* HAVE_BUTTON_LIGHT */ 846#endif /* HAVE_BUTTON_LIGHT */
843#endif /* HAVE_MULTIDRIVE */ 847#endif /* HAVE_MULTIDRIVE */
844 CGU_IDE |= (1<<7) /* AHB interface enable */ |
845 (1<<6) /* interface enable */;
846 sd_enabled = true; 848 sd_enabled = true;
847 849
848#ifdef HAVE_HOTSWAP 850#ifdef HAVE_HOTSWAP
@@ -855,25 +857,29 @@ void sd_enable(bool on)
855 } 857 }
856 else 858 else
857 { 859 {
858 CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; 860#ifdef HAVE_HOTSWAP
861 if(cpu_boosted)
862 {
863 cpu_boost(false);
864 cpu_boosted = false;
865 }
866#endif
867 sd_enabled = false;
868
859#ifdef HAVE_MULTIDRIVE 869#ifdef HAVE_MULTIDRIVE
860#ifdef HAVE_BUTTON_LIGHT 870#ifdef HAVE_BUTTON_LIGHT
861 CCU_IO &= ~(1<<2); 871 CCU_IO &= ~(1<<2); /* XPD is general purpose IO (b3:2 = 00) */
862 if (buttonlight_is_on) 872 if (buttonlight_is_on)
863 _buttonlight_on(); 873 _buttonlight_on();
864#endif /* HAVE_BUTTON_LIGHT */ 874#endif /* HAVE_BUTTON_LIGHT */
875 /* Disable MCI clk for uSD */
865 CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE; 876 CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE;
866#endif /* HAVE_MULTIDRIVE */ 877#endif /* HAVE_MULTIDRIVE */
867 CGU_IDE &= ~((1<<7)|(1<<6));
868 sd_enabled = false;
869 878
870#ifdef HAVE_HOTSWAP 879 /* Disable both NAF_CLOCK & IDE clk for internal SD */
871 if(cpu_boosted) 880 CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE;
872 { 881 CGU_IDE &= ~((1<<7) /* IDE AHB interface disable */
873 cpu_boost(false); 882 | (1<<6)); /* IDE interface disable */
874 cpu_boosted = false;
875 }
876#endif
877 } 883 }
878} 884}
879 885