summaryrefslogtreecommitdiff
path: root/firmware/drivers/m66591.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/m66591.c')
-rw-r--r--firmware/drivers/m66591.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/firmware/drivers/m66591.c b/firmware/drivers/m66591.c
index 9a93985580..4c1773e61b 100644
--- a/firmware/drivers/m66591.c
+++ b/firmware/drivers/m66591.c
@@ -423,29 +423,29 @@ void USB_DEVICE(void) {
423 M66591_INTSTAT_NRDY, M66591_INTSTAT_EMP); 423 M66591_INTSTAT_NRDY, M66591_INTSTAT_EMP);
424 424
425 /* VBUS (connected) interrupt */ 425 /* VBUS (connected) interrupt */
426 while ( M66591_INTSTAT_MAIN & (1<<15) ) { 426 while ( M66591_INTSTAT_MAIN & (1<<15) ) {
427 M66591_INTSTAT_MAIN &= ~(1<<15); 427 M66591_INTSTAT_MAIN &= ~(1<<15);
428 428
429 /* If device is not clocked, interrupt flag must be set manually */ 429 /* If device is not clocked, interrupt flag must be set manually */
430 if ( !(M66591_TRN_CTRL & (1<<10)) ) { 430 if ( !(M66591_TRN_CTRL & (1<<10)) ) {
431 M66591_INTSTAT_MAIN |= (1<<15); 431 M66591_INTSTAT_MAIN |= (1<<15);
432 } 432 }
433 } 433 }
434 434
435 /* Resume interrupt: This is not used. Extra logic needs to be added similar 435 /* Resume interrupt: This is not used. Extra logic needs to be added similar
436 * to the VBUS interrupt incase the PHY clock is not running. 436 * to the VBUS interrupt incase the PHY clock is not running.
437 */ 437 */
438 if(M66591_INTSTAT_MAIN & (1<<14)) { 438 if(M66591_INTSTAT_MAIN & (1<<14)) {
439 M66591_INTSTAT_MAIN &= ~(1<<14); 439 M66591_INTSTAT_MAIN &= ~(1<<14);
440 logf("mxx: RESUME"); 440 logf("mxx: RESUME");
441 } 441 }
442 442
443 /* Device state transition interrupt: Not used, but useful for debugging */ 443 /* Device state transition interrupt: Not used, but useful for debugging */
444 if(M66591_INTSTAT_MAIN & (1<<12)) { 444 if(M66591_INTSTAT_MAIN & (1<<12)) {
445 M66591_INTSTAT_MAIN &= ~(1<<12); 445 M66591_INTSTAT_MAIN &= ~(1<<12);
446 logf("mxx: DEV state CHANGE=%d", 446 logf("mxx: DEV state CHANGE=%d",
447 ((M66591_INTSTAT_MAIN & (0x07<<4)) >> 4) ); 447 ((M66591_INTSTAT_MAIN & (0x07<<4)) >> 4) );
448 } 448 }
449 449
450 /* Control transfer stage interrupt */ 450 /* Control transfer stage interrupt */
451 if(M66591_INTSTAT_MAIN & (1<<11)) { 451 if(M66591_INTSTAT_MAIN & (1<<11)) {
@@ -721,30 +721,30 @@ void usb_drv_exit(void) {
721 * Reference Manual Rev 1.00, p. 78. 721 * Reference Manual Rev 1.00, p. 78.
722 */ 722 */
723 723
724 /* Detach notification to PC (disable D+ pull-up) */ 724 /* Detach notification to PC (disable D+ pull-up) */
725 M66591_TRN_CTRL &= ~(1<<4); 725 M66591_TRN_CTRL &= ~(1<<4);
726
727 /* Software reset */
728 M66591_TRN_CTRL &= ~0x01;
726 729
727 /* Software reset */ 730 /* Disable internal clock supply */
728 M66591_TRN_CTRL &= ~0x01; 731 M66591_TRN_CTRL &= ~(1<<10);
732 udelay(3);
729 733
730 /* Disable internal clock supply */ 734 /* Disable PLL */
731 M66591_TRN_CTRL &= ~(1<<10); 735 M66591_TRN_CTRL &= ~(1<<11);
732 udelay(3); 736 udelay(3);
733 737
734 /* Disable PLL */ 738 /* Disable internal reference clock */
735 M66591_TRN_CTRL &= ~(1<<11); 739 M66591_TRN_CTRL &= ~(1<<12);
736 udelay(3); 740 udelay(3);
737 741
738 /* Disable internal reference clock */ 742 /* Disable oscillation buffer, reenable USB operation */
739 M66591_TRN_CTRL &= ~(1<<12); 743 M66591_TRN_CTRL &= ~(1<<13);
740 udelay(3);
741 744
742 /* Disable oscillation buffer, reenable USB operation */ 745 M66591_TRN_CTRL |= 0x01;
743 M66591_TRN_CTRL &= ~(1<<13);
744
745 M66591_TRN_CTRL |= 0x01;
746 746
747 logf("mxx: detached"); 747 logf("mxx: detached");
748} 748}
749 749
750/* This function begins a transmit (on an IN endpoint), it should not block 750/* This function begins a transmit (on an IN endpoint), it should not block