summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sd-as3525v2.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-07-19 15:29:28 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-07-19 15:29:28 +0000
commite44b65c806fa4fa7a30a9c2a4dce7f82d859ac09 (patch)
treea2ef06c69408bbed8847cc8e0b5c46fb46549482 /firmware/target/arm/as3525/sd-as3525v2.c
parenta083b9a9e083f3c1fca35becdcbe25d606ed3dff (diff)
downloadrockbox-e44b65c806fa4fa7a30a9c2a4dce7f82d859ac09.tar.gz
rockbox-e44b65c806fa4fa7a30a9c2a4dce7f82d859ac09.zip
Support new Fuzev2 revisions (fuzev2_variant == 1)
- Revert BUTTON_HOME - Modifications to SD driver (µSD not working yet) TODO: µSD and FM radio git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27492 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/sd-as3525v2.c')
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 85913ec9dc..d42a086770 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -394,6 +394,8 @@ static inline bool card_detect_target(void)
394static bool send_cmd(const int drive, const int cmd, const int arg, const int flags, 394static bool send_cmd(const int drive, const int cmd, const int arg, const int flags,
395 unsigned long *response) 395 unsigned long *response)
396{ 396{
397 int card_no;
398
397#if defined(HAVE_MULTIDRIVE) 399#if defined(HAVE_MULTIDRIVE)
398 if(sd_present(SD_SLOT_AS3525)) 400 if(sd_present(SD_SLOT_AS3525))
399 GPIOB_PIN(5) = (1-drive) << 5; 401 GPIOB_PIN(5) = (1-drive) << 5;
@@ -401,6 +403,13 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
401 403
402 MCI_ARGUMENT = arg; 404 MCI_ARGUMENT = arg;
403 405
406#ifdef SANSA_FUZEV2
407 if (fuzev2_variant == 1)
408 card_no = 1 << 16;
409 else
410#endif
411 card_no = CMD_CARD_NO(drive);
412
404 /* Construct MCI_COMMAND */ 413 /* Construct MCI_COMMAND */
405 MCI_COMMAND = 414 MCI_COMMAND =
406 /*b5:0*/ cmd 415 /*b5:0*/ cmd
@@ -414,7 +423,7 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl
414 /*b13 */ | (TRANSFER_CMD ? CMD_WAIT_PRV_DAT_BIT: 0) 423 /*b13 */ | (TRANSFER_CMD ? CMD_WAIT_PRV_DAT_BIT: 0)
415 /*b14 | CMD_ABRT_CMD_BIT unused */ 424 /*b14 | CMD_ABRT_CMD_BIT unused */
416 /*b15 | CMD_SEND_INIT_BIT unused */ 425 /*b15 | CMD_SEND_INIT_BIT unused */
417 /*b20:16 */ | CMD_CARD_NO(drive) 426 /*b20:16 */ | card_no
418 /*b21 | CMD_SEND_CLK_ONLY unused */ 427 /*b21 | CMD_SEND_CLK_ONLY unused */
419 /*b22 | CMD_READ_CEATA unused */ 428 /*b22 | CMD_READ_CEATA unused */
420 /*b23 | CMD_CCS_EXPECTED unused */ 429 /*b23 | CMD_CCS_EXPECTED unused */
@@ -580,13 +589,26 @@ static int sd_init_card(const int drive)
580 /* ACMD42 */ 589 /* ACMD42 */
581 if(!send_cmd(drive, SD_SET_CLR_CARD_DETECT, 0, MCI_NO_RESP, NULL)) 590 if(!send_cmd(drive, SD_SET_CLR_CARD_DETECT, 0, MCI_NO_RESP, NULL))
582 return -17; 591 return -17;
592
583 /* Now that card is widebus make controller aware */ 593 /* Now that card is widebus make controller aware */
584 MCI_CTYPE |= (1<<drive); 594#ifdef SANSA_FUZEV2
595 if (fuzev2_variant == 1)
596 MCI_CTYPE |= 1<<1;
597 else
585#endif 598#endif
599 MCI_CTYPE |= (1<<drive);
586 600
587 card_info[drive].initialized = 1; 601#endif /* ! BOOTLOADER */
602
603 /* Set low power mode */
604#ifdef SANSA_FUZEV2
605 if (fuzev2_variant == 1)
606 MCI_CLKENA |= 1<<16;
607 else
608#endif
609 MCI_CLKENA |= 1<<(drive + 16);
588 610
589 MCI_CLKENA |= 1<<(drive + 16); /* Set low power mode */ 611 card_info[drive].initialized = 1;
590 612
591 return 0; 613 return 0;
592} 614}
@@ -682,14 +704,17 @@ static void init_controller(void)
682{ 704{
683 int hcon_numcards = ((MCI_HCON>>1) & 0x1F) + 1; 705 int hcon_numcards = ((MCI_HCON>>1) & 0x1F) + 1;
684 int card_mask = (1 << hcon_numcards) - 1; 706 int card_mask = (1 << hcon_numcards) - 1;
707 int pwr_mask;
685 708
686 MCI_PWREN &= ~card_mask; /* power off all cards */ 709#ifdef SANSA_FUZEV2
687 710 if (fuzev2_variant == 1)
688 MCI_CLKSRC = 0x00; /* All CLK_SRC_CRD set to 0*/ 711 pwr_mask = 1 << 1;
689 MCI_CLKDIV = 0x00; /* CLK_DIV_0 : bits 7:0 */ 712 else
713#endif
714 pwr_mask = card_mask;
690 715
691 MCI_PWREN |= card_mask; /* power up cards */ 716 MCI_PWREN &= ~pwr_mask; /* power off all cards */
692 mci_delay(); 717 MCI_PWREN = pwr_mask; /* power up cards */
693 718
694 MCI_CTRL |= CTRL_RESET; 719 MCI_CTRL |= CTRL_RESET;
695 while(MCI_CTRL & CTRL_RESET) 720 while(MCI_CTRL & CTRL_RESET)
@@ -745,6 +770,7 @@ int sd_init(void)
745 770
746 wakeup_init(&transfer_completion_signal); 771 wakeup_init(&transfer_completion_signal);
747 wakeup_init(&command_completion_signal); 772 wakeup_init(&command_completion_signal);
773
748#ifdef HAVE_MULTIDRIVE 774#ifdef HAVE_MULTIDRIVE
749 /* clear previous irq */ 775 /* clear previous irq */
750 GPIOA_IC = EXT_SD_BITS; 776 GPIOA_IC = EXT_SD_BITS;
@@ -754,7 +780,9 @@ int sd_init(void)
754 GPIOA_IBE |= EXT_SD_BITS; 780 GPIOA_IBE |= EXT_SD_BITS;
755 /* enable the card detect interrupt */ 781 /* enable the card detect interrupt */
756 GPIOA_IE |= EXT_SD_BITS; 782 GPIOA_IE |= EXT_SD_BITS;
783#endif /* HAVE_MULTIDRIVE */
757 784
785#ifndef SANSA_CLIPV2
758 /* Configure XPD for SD-MCI interface */ 786 /* Configure XPD for SD-MCI interface */
759 CCU_IO |= (1<<2); 787 CCU_IO |= (1<<2);
760#endif 788#endif