diff options
Diffstat (limited to 'firmware')
-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) | |||
268 | { | 268 | { |
269 | while(1) | 269 | while(1) |
270 | { | 270 | { |
271 | #ifdef SANSA_C200V2 | 271 | #if defined(SANSA_C200V2) || defined(SANSA_FUZEV2) |
272 | lcd_clear_display(); | 272 | lcd_clear_display(); |
273 | line = 0; | 273 | line = 0; |
274 | lcd_puts(0, line++, "[Submodel:]"); | 274 | lcd_puts(0, line++, "[Submodel:]"); |
275 | #if defined(SANSA_C200V2) | ||
275 | lcd_putsf(0, line++, "C200v2 variant %d", c200v2_variant); | 276 | lcd_putsf(0, line++, "C200v2 variant %d", c200v2_variant); |
277 | #elif defined(SANSA_FUZEV2) | ||
278 | lcd_putsf(0, line++, "Fuzev2 variant %d", fuzev2_variant); | ||
279 | #endif | ||
276 | lcd_update(); | 280 | lcd_update(); |
277 | int btn = button_get_w_tmo(HZ/10); | 281 | int btn = button_get_w_tmo(HZ/10); |
278 | if(btn == (DEBUG_CANCEL|BUTTON_REL)) | 282 | 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) | |||
257 | btn |= BUTTON_RIGHT; | 257 | btn |= BUTTON_RIGHT; |
258 | if (GPIOB_PIN(1) & 1<<1) | 258 | if (GPIOB_PIN(1) & 1<<1) |
259 | btn |= BUTTON_HOME; | 259 | btn |= BUTTON_HOME; |
260 | if (fuzev2_variant == 1) | ||
261 | btn ^= BUTTON_HOME; | ||
262 | |||
260 | if (gpiod6 & 1<<6) | 263 | if (gpiod6 & 1<<6) |
261 | { /* power/hold is on the same pin. we know it's hold if the bit isn't | 264 | { /* power/hold is on the same pin. we know it's hold if the bit isn't |
262 | * set now anymore */ | 265 | * 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) | |||
394 | static bool send_cmd(const int drive, const int cmd, const int arg, const int flags, | 394 | static 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 |
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) | |||
173 | } | 173 | } |
174 | 174 | ||
175 | #if defined(SANSA_C200V2) | 175 | #if defined(SANSA_C200V2) |
176 | #include "dbop-as3525.h" | 176 | int c200v2_variant; |
177 | |||
178 | int c200v2_variant = 0; | ||
179 | 177 | ||
180 | static void check_model_variant(void) | 178 | static void check_model_variant(void) |
181 | { | 179 | { |
@@ -188,24 +186,22 @@ static void check_model_variant(void) | |||
188 | * to charge the input capacitance */ | 186 | * to charge the input capacitance */ |
189 | for (i=0; i<1000; i++) asm volatile ("nop\n"); | 187 | for (i=0; i<1000; i++) asm volatile ("nop\n"); |
190 | /* read the pullup/pulldown value on A7 to determine the variant */ | 188 | /* read the pullup/pulldown value on A7 to determine the variant */ |
191 | if (GPIOA_PIN(7) == 0) { | 189 | c200v2_variant = !GPIOA_PIN(7); |
192 | /* | ||
193 | * Backlight on A7. | ||
194 | */ | ||
195 | c200v2_variant = 1; | ||
196 | } else { | ||
197 | /* | ||
198 | * Backlight on A5. | ||
199 | */ | ||
200 | c200v2_variant = 0; | ||
201 | } | ||
202 | GPIOA_DIR = saved_dir; | 190 | GPIOA_DIR = saved_dir; |
203 | } | 191 | } |
192 | #elif defined(SANSA_FUZEV2) | ||
193 | int fuzev2_variant; | ||
194 | |||
195 | static void check_model_variant(void) | ||
196 | { | ||
197 | GPIOB_DIR &= ~(1<<5); | ||
198 | fuzev2_variant = !!GPIOB_PIN(5); | ||
199 | } | ||
204 | #else | 200 | #else |
205 | static inline void check_model_variant(void) | 201 | static inline void check_model_variant(void) |
206 | { | 202 | { |
207 | } | 203 | } |
208 | #endif /* SANSA_C200V2*/ | 204 | #endif /* model selection */ |
209 | 205 | ||
210 | void system_init(void) | 206 | void system_init(void) |
211 | { | 207 | { |
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 @@ | |||
46 | ? (((uintptr_t)(a)) - IRAM_ORIG) \ | 46 | ? (((uintptr_t)(a)) - IRAM_ORIG) \ |
47 | : ((uintptr_t)(a)))) | 47 | : ((uintptr_t)(a)))) |
48 | 48 | ||
49 | #ifdef SANSA_FUZEV2 | ||
50 | extern int fuzev2_variant; | ||
51 | #endif | ||
52 | |||
49 | #ifdef SANSA_C200V2 | 53 | #ifdef SANSA_C200V2 |
50 | /* 0: Backlight on A5, 1: Backlight on A7 */ | 54 | /* 0: Backlight on A5, 1: Backlight on A7 */ |
51 | extern int c200v2_variant; | 55 | extern int c200v2_variant; |