diff options
-rw-r--r-- | firmware/target/arm/as3525/debug-as3525.c | 6 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c | 3 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sd-as3525v2.c | 48 | ||||
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 26 | ||||
-rw-r--r-- | firmware/target/arm/as3525/system-target.h | 4 |
5 files changed, 61 insertions, 26 deletions
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c index 71a8a85022..6e52d1d653 100644 --- a/firmware/target/arm/as3525/debug-as3525.c +++ b/firmware/target/arm/as3525/debug-as3525.c @@ -268,11 +268,15 @@ bool __dbg_hw_info(void) { while(1) { -#ifdef SANSA_C200V2 +#if defined(SANSA_C200V2) || defined(SANSA_FUZEV2) lcd_clear_display(); line = 0; lcd_puts(0, line++, "[Submodel:]"); +#if defined(SANSA_C200V2) lcd_putsf(0, line++, "C200v2 variant %d", c200v2_variant); +#elif defined(SANSA_FUZEV2) + lcd_putsf(0, line++, "Fuzev2 variant %d", fuzev2_variant); +#endif lcd_update(); int btn = button_get_w_tmo(HZ/10); if(btn == (DEBUG_CANCEL|BUTTON_REL)) diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c index 060933d0ac..5ec2025667 100644 --- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c +++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c @@ -257,6 +257,9 @@ int button_read_device(void) btn |= BUTTON_RIGHT; if (GPIOB_PIN(1) & 1<<1) btn |= BUTTON_HOME; + if (fuzev2_variant == 1) + btn ^= BUTTON_HOME; + if (gpiod6 & 1<<6) { /* power/hold is on the same pin. we know it's hold if the bit isn't * set now anymore */ 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) static bool send_cmd(const int drive, const int cmd, const int arg, const int flags, unsigned long *response) { + int card_no; + #if defined(HAVE_MULTIDRIVE) if(sd_present(SD_SLOT_AS3525)) 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 MCI_ARGUMENT = arg; +#ifdef SANSA_FUZEV2 + if (fuzev2_variant == 1) + card_no = 1 << 16; + else +#endif + card_no = CMD_CARD_NO(drive); + /* Construct MCI_COMMAND */ MCI_COMMAND = /*b5:0*/ cmd @@ -414,7 +423,7 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl /*b13 */ | (TRANSFER_CMD ? CMD_WAIT_PRV_DAT_BIT: 0) /*b14 | CMD_ABRT_CMD_BIT unused */ /*b15 | CMD_SEND_INIT_BIT unused */ - /*b20:16 */ | CMD_CARD_NO(drive) + /*b20:16 */ | card_no /*b21 | CMD_SEND_CLK_ONLY unused */ /*b22 | CMD_READ_CEATA unused */ /*b23 | CMD_CCS_EXPECTED unused */ @@ -580,13 +589,26 @@ static int sd_init_card(const int drive) /* ACMD42 */ if(!send_cmd(drive, SD_SET_CLR_CARD_DETECT, 0, MCI_NO_RESP, NULL)) return -17; + /* Now that card is widebus make controller aware */ - MCI_CTYPE |= (1<<drive); +#ifdef SANSA_FUZEV2 + if (fuzev2_variant == 1) + MCI_CTYPE |= 1<<1; + else #endif + MCI_CTYPE |= (1<<drive); - card_info[drive].initialized = 1; +#endif /* ! BOOTLOADER */ + + /* Set low power mode */ +#ifdef SANSA_FUZEV2 + if (fuzev2_variant == 1) + MCI_CLKENA |= 1<<16; + else +#endif + MCI_CLKENA |= 1<<(drive + 16); - MCI_CLKENA |= 1<<(drive + 16); /* Set low power mode */ + card_info[drive].initialized = 1; return 0; } @@ -682,14 +704,17 @@ static void init_controller(void) { int hcon_numcards = ((MCI_HCON>>1) & 0x1F) + 1; int card_mask = (1 << hcon_numcards) - 1; + int pwr_mask; - MCI_PWREN &= ~card_mask; /* power off all cards */ - - MCI_CLKSRC = 0x00; /* All CLK_SRC_CRD set to 0*/ - MCI_CLKDIV = 0x00; /* CLK_DIV_0 : bits 7:0 */ +#ifdef SANSA_FUZEV2 + if (fuzev2_variant == 1) + pwr_mask = 1 << 1; + else +#endif + pwr_mask = card_mask; - MCI_PWREN |= card_mask; /* power up cards */ - mci_delay(); + MCI_PWREN &= ~pwr_mask; /* power off all cards */ + MCI_PWREN = pwr_mask; /* power up cards */ MCI_CTRL |= CTRL_RESET; while(MCI_CTRL & CTRL_RESET) @@ -745,6 +770,7 @@ int sd_init(void) wakeup_init(&transfer_completion_signal); wakeup_init(&command_completion_signal); + #ifdef HAVE_MULTIDRIVE /* clear previous irq */ GPIOA_IC = EXT_SD_BITS; @@ -754,7 +780,9 @@ int sd_init(void) GPIOA_IBE |= EXT_SD_BITS; /* enable the card detect interrupt */ GPIOA_IE |= EXT_SD_BITS; +#endif /* HAVE_MULTIDRIVE */ +#ifndef SANSA_CLIPV2 /* Configure XPD for SD-MCI interface */ CCU_IO |= (1<<2); #endif diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 2e4747efaf..8f6291201f 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -173,9 +173,7 @@ void fiq_handler(void) } #if defined(SANSA_C200V2) -#include "dbop-as3525.h" - -int c200v2_variant = 0; +int c200v2_variant; static void check_model_variant(void) { @@ -188,24 +186,22 @@ static void check_model_variant(void) * to charge the input capacitance */ for (i=0; i<1000; i++) asm volatile ("nop\n"); /* read the pullup/pulldown value on A7 to determine the variant */ - if (GPIOA_PIN(7) == 0) { - /* - * Backlight on A7. - */ - c200v2_variant = 1; - } else { - /* - * Backlight on A5. - */ - c200v2_variant = 0; - } + c200v2_variant = !GPIOA_PIN(7); GPIOA_DIR = saved_dir; } +#elif defined(SANSA_FUZEV2) +int fuzev2_variant; + +static void check_model_variant(void) +{ + GPIOB_DIR &= ~(1<<5); + fuzev2_variant = !!GPIOB_PIN(5); +} #else static inline void check_model_variant(void) { } -#endif /* SANSA_C200V2*/ +#endif /* model selection */ void system_init(void) { diff --git a/firmware/target/arm/as3525/system-target.h b/firmware/target/arm/as3525/system-target.h index b3b9001a45..249e062fec 100644 --- a/firmware/target/arm/as3525/system-target.h +++ b/firmware/target/arm/as3525/system-target.h @@ -46,6 +46,10 @@ ? (((uintptr_t)(a)) - IRAM_ORIG) \ : ((uintptr_t)(a)))) +#ifdef SANSA_FUZEV2 +extern int fuzev2_variant; +#endif + #ifdef SANSA_C200V2 /* 0: Backlight on A5, 1: Backlight on A7 */ extern int c200v2_variant; |