From 8f1ace7525057b6dfe8b6be96c987d6449057524 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 22 May 2005 00:42:00 +0000 Subject: Ondio: Fix multivolume and hotswap for the old MMC clock circuit. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6502 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata_mmc.c | 17 ++++++++--------- firmware/export/ata_mmc.h | 2 +- firmware/usb.c | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 6876ce0ec9..2e5bd3d78f 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -173,21 +173,20 @@ static void mmc_tick(void); /* implementation */ -void mmc_select_clock(int card_no) +void mmc_enable_int_flash_clock(bool on) { - /* set clock gate for external card / reset for internal card if the - * MMC clock polarity bit is 0, vice versa if it is 1 */ - if ((card_no != 0) ^ new_mmc_circuit) - or_b(0x10, &PADRH); /* set clock gate PA12 */ - else + /* Internal flash clock is enabled by setting PA12 high with the new + * clock circuit, and by setting it low with the old clock circuit */ + if (on ^ new_mmc_circuit) and_b(~0x10, &PADRH); /* clear clock gate PA12 */ + else + or_b(0x10, &PADRH); /* set clock gate PA12 */ } static int select_card(int card_no) { mutex_lock(&mmc_mutex); led(true); - mmc_select_clock(card_no); last_disk_activity = current_tick; if (!card_info[card_no].initialized) @@ -1061,7 +1060,6 @@ bool mmc_touched(void) 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); @@ -1144,6 +1142,7 @@ void ata_enable(bool on) { PBCR1 |= 0x08A0; /* as SCK1, TxD1, RxD1 */ IPRE &= 0x0FFF; /* disable SCI1 interrupts for the CPU */ + mmc_enable_int_flash_clock(true); /* always enabled in SPI mode */ } and_b(~0x80, &PADRL); /* assert reset */ sleep(HZ/20); @@ -1183,13 +1182,13 @@ int ata_init(void) } #endif + new_mmc_circuit = ((read_hw_mask() & MMC_CLOCK_POLARITY) != 0); ata_enable(true); if ( !initialized ) { if (!last_mmc_status) mmc_status = MMC_UNTOUCHED; - new_mmc_circuit = ((read_hw_mask() & MMC_CLOCK_POLARITY) != 0); #ifdef HAVE_HOTSWAP queue_init(&mmc_queue); create_thread(mmc_thread, mmc_stack, diff --git a/firmware/export/ata_mmc.h b/firmware/export/ata_mmc.h index 9da93906ad..a4e9f71f09 100644 --- a/firmware/export/ata_mmc.h +++ b/firmware/export/ata_mmc.h @@ -39,7 +39,7 @@ typedef struct unsigned int block_exp; /* block size exponent */ } tCardInfo; -void mmc_select_clock(int card_no); +void mmc_enable_int_flash_clock(bool on); bool mmc_detect(void); unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start, unsigned int size); diff --git a/firmware/usb.c b/firmware/usb.c index 6095bcd65e..a514f8f0b4 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -88,7 +88,7 @@ static void usb_enable(bool on) if(on) { #ifdef HAVE_MMC - mmc_select_clock(mmc_detect() ? 1 : 0); + mmc_enable_int_flash_clock(!mmc_detect()); #endif if (!(read_hw_mask() & MMC_CLOCK_POLARITY)) and_b(~0x20, &PBDRH); /* old circuit needs SCK1 = low while on USB */ -- cgit v1.2.3