diff options
Diffstat (limited to 'firmware/system.c')
-rw-r--r-- | firmware/system.c | 237 |
1 files changed, 146 insertions, 91 deletions
diff --git a/firmware/system.c b/firmware/system.c index a86d945093..a9c9d9e350 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -612,12 +612,22 @@ extern void ipod_mini_button_int(void); | |||
612 | 612 | ||
613 | void irq(void) | 613 | void irq(void) |
614 | { | 614 | { |
615 | if (CPU_INT_STAT & TIMER1_MASK) | 615 | if(CURRENT_CORE == CPU) |
616 | TIMER1(); | 616 | { |
617 | else if (CPU_INT_STAT & TIMER2_MASK) | 617 | if (CPU_INT_STAT & TIMER1_MASK) |
618 | TIMER2(); | 618 | TIMER1(); |
619 | else if (CPU_HI_INT_STAT & GPIO_MASK) | 619 | else if (CPU_INT_STAT & TIMER2_MASK) |
620 | ipod_mini_button_int(); | 620 | TIMER2(); |
621 | else if (CPU_HI_INT_STAT & GPIO_MASK) | ||
622 | ipod_mini_button_int(); | ||
623 | } else { | ||
624 | if (COP_INT_STAT & TIMER1_MASK) | ||
625 | TIMER1(); | ||
626 | else if (COP_INT_STAT & TIMER2_MASK) | ||
627 | TIMER2(); | ||
628 | else if (COP_HI_INT_STAT & GPIO_MASK) | ||
629 | ipod_mini_button_int(); | ||
630 | } | ||
621 | } | 631 | } |
622 | #elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB) || defined(ELIO_TPJ1022) \ | 632 | #elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB) || defined(ELIO_TPJ1022) \ |
623 | || (defined SANSA_E200) | 633 | || (defined SANSA_E200) |
@@ -626,22 +636,40 @@ void irq(void) | |||
626 | /* TODO: Even if it isn't in the target tree, this should be the default case */ | 636 | /* TODO: Even if it isn't in the target tree, this should be the default case */ |
627 | void irq(void) | 637 | void irq(void) |
628 | { | 638 | { |
629 | if (CPU_INT_STAT & TIMER1_MASK) | 639 | if(CURRENT_CORE == CPU) |
630 | TIMER1(); | 640 | { |
631 | else if (CPU_INT_STAT & TIMER2_MASK) | 641 | if (CPU_INT_STAT & TIMER1_MASK) |
632 | TIMER2(); | 642 | TIMER1(); |
643 | else if (CPU_INT_STAT & TIMER2_MASK) | ||
644 | TIMER2(); | ||
645 | } else { | ||
646 | if (COP_INT_STAT & TIMER1_MASK) | ||
647 | TIMER1(); | ||
648 | else if (COP_INT_STAT & TIMER2_MASK) | ||
649 | TIMER2(); | ||
650 | } | ||
633 | } | 651 | } |
634 | #else | 652 | #else |
635 | extern void ipod_4g_button_int(void); | 653 | extern void ipod_4g_button_int(void); |
636 | 654 | ||
637 | void irq(void) | 655 | void irq(void) |
638 | { | 656 | { |
639 | if (CPU_INT_STAT & TIMER1_MASK) | 657 | if(CURRENT_CORE == CPU) |
640 | TIMER1(); | 658 | { |
641 | else if (CPU_INT_STAT & TIMER2_MASK) | 659 | if (CPU_INT_STAT & TIMER1_MASK) |
642 | TIMER2(); | 660 | TIMER1(); |
643 | else if (CPU_HI_INT_STAT & I2C_MASK) | 661 | else if (CPU_INT_STAT & TIMER2_MASK) |
644 | ipod_4g_button_int(); | 662 | TIMER2(); |
663 | else if (CPU_HI_INT_STAT & I2C_MASK) | ||
664 | ipod_4g_button_int(); | ||
665 | } else { | ||
666 | if (COP_INT_STAT & TIMER1_MASK) | ||
667 | TIMER1(); | ||
668 | else if (COP_INT_STAT & TIMER2_MASK) | ||
669 | TIMER2(); | ||
670 | else if (COP_HI_INT_STAT & I2C_MASK) | ||
671 | ipod_4g_button_int(); | ||
672 | } | ||
645 | } | 673 | } |
646 | #endif | 674 | #endif |
647 | #endif /* BOOTLOADER */ | 675 | #endif /* BOOTLOADER */ |
@@ -694,43 +722,47 @@ void set_cpu_frequency(long frequency) | |||
694 | { | 722 | { |
695 | unsigned long postmult; | 723 | unsigned long postmult; |
696 | 724 | ||
697 | if (frequency == CPUFREQ_NORMAL) | 725 | if (CURRENT_CORE == CPU) |
698 | postmult = CPUFREQ_NORMAL_MULT; | 726 | { |
699 | else if (frequency == CPUFREQ_MAX) | 727 | if (frequency == CPUFREQ_NORMAL) |
700 | postmult = CPUFREQ_MAX_MULT; | 728 | postmult = CPUFREQ_NORMAL_MULT; |
701 | else | 729 | else if (frequency == CPUFREQ_MAX) |
702 | postmult = CPUFREQ_DEFAULT_MULT; | 730 | postmult = CPUFREQ_MAX_MULT; |
703 | cpu_frequency = frequency; | 731 | else |
732 | postmult = CPUFREQ_DEFAULT_MULT; | ||
733 | cpu_frequency = frequency; | ||
704 | 734 | ||
705 | /* Enable PLL? */ | 735 | /* Enable PLL? */ |
706 | outl(inl(0x70000020) | (1<<30), 0x70000020); | 736 | outl(inl(0x70000020) | (1<<30), 0x70000020); |
707 | 737 | ||
708 | /* Select 24MHz crystal as clock source? */ | 738 | /* Select 24MHz crystal as clock source? */ |
709 | outl((inl(0x60006020) & 0x0fffff0f) | 0x20000020, 0x60006020); | 739 | outl((inl(0x60006020) & 0x0fffff0f) | 0x20000020, 0x60006020); |
710 | 740 | ||
711 | /* Clock frequency = (24/8)*postmult */ | 741 | /* Clock frequency = (24/8)*postmult */ |
712 | outl(0xaa020000 | 8 | (postmult << 8), 0x60006034); | 742 | outl(0xaa020000 | 8 | (postmult << 8), 0x60006034); |
713 | 743 | ||
714 | /* Wait for PLL relock? */ | 744 | /* Wait for PLL relock? */ |
715 | udelay(2000); | 745 | udelay(2000); |
716 | 746 | ||
717 | /* Select PLL as clock source? */ | 747 | /* Select PLL as clock source? */ |
718 | outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020); | 748 | outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020); |
719 | 749 | ||
720 | #if defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IRIVER_H10) || defined(IRIVER_H10_5GB) | 750 | #if defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IRIVER_H10) || defined(IRIVER_H10_5GB) |
721 | /* We don't know why the timer interrupt gets disabled on the PP5020 | 751 | /* We don't know why the timer interrupt gets disabled on the PP5020 |
722 | based ipods, but without the following line, the 4Gs will freeze | 752 | based ipods, but without the following line, the 4Gs will freeze |
723 | when CPU frequency changing is enabled. | 753 | when CPU frequency changing is enabled. |
724 | 754 | ||
725 | Note also that a simple "CPU_INT_EN = TIMER1_MASK;" (as used | 755 | Note also that a simple "CPU_INT_EN = TIMER1_MASK;" (as used |
726 | elsewhere to enable interrupts) doesn't work, we need "|=". | 756 | elsewhere to enable interrupts) doesn't work, we need "|=". |
727 | 757 | ||
728 | It's not needed on the PP5021 and PP5022 ipods. | 758 | It's not needed on the PP5021 and PP5022 ipods. |
729 | */ | 759 | */ |
730 | 760 | ||
731 | /* unmask interrupt source */ | 761 | /* unmask interrupt source */ |
732 | CPU_INT_EN |= TIMER1_MASK; | 762 | CPU_INT_EN |= TIMER1_MASK; |
763 | COP_INT_EN |= TIMER1_MASK; | ||
733 | #endif | 764 | #endif |
765 | } | ||
734 | } | 766 | } |
735 | #elif !defined(BOOTLOADER) | 767 | #elif !defined(BOOTLOADER) |
736 | void ipod_set_cpu_frequency(void) | 768 | void ipod_set_cpu_frequency(void) |
@@ -754,24 +786,33 @@ void ipod_set_cpu_frequency(void) | |||
754 | void system_init(void) | 786 | void system_init(void) |
755 | { | 787 | { |
756 | #ifndef BOOTLOADER | 788 | #ifndef BOOTLOADER |
757 | /* Remap the flash ROM from 0x00000000 to 0x20000000. */ | 789 | if (CURRENT_CORE == CPU) |
758 | MMAP3_LOGICAL = 0x20000000 | 0x3a00; | 790 | { |
759 | MMAP3_PHYSICAL = 0x00000000 | 0x3f84; | 791 | /* Remap the flash ROM from 0x00000000 to 0x20000000. */ |
760 | 792 | MMAP3_LOGICAL = 0x20000000 | 0x3a00; | |
761 | /* The hw revision is written to the last 4 bytes of SDRAM by the | 793 | MMAP3_PHYSICAL = 0x00000000 | 0x3f84; |
762 | bootloader - we save it before Rockbox overwrites it. */ | 794 | |
763 | ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc))); | 795 | /* The hw revision is written to the last 4 bytes of SDRAM by the |
764 | 796 | bootloader - we save it before Rockbox overwrites it. */ | |
765 | /* disable all irqs */ | 797 | ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc))); |
766 | outl(-1, 0x60001138); | 798 | |
767 | outl(-1, 0x60001128); | 799 | /* disable all irqs */ |
768 | outl(-1, 0x6000111c); | 800 | outl(-1, 0x60001138); |
769 | 801 | outl(-1, 0x60001128); | |
770 | outl(-1, 0x60001038); | 802 | outl(-1, 0x6000111c); |
771 | outl(-1, 0x60001028); | 803 | |
772 | outl(-1, 0x6000101c); | 804 | outl(-1, 0x60001038); |
773 | #ifndef HAVE_ADJUSTABLE_CPU_FREQ | 805 | outl(-1, 0x60001028); |
774 | ipod_set_cpu_frequency(); | 806 | outl(-1, 0x6000101c); |
807 | #if (!defined HAVE_ADJUSTABLE_CPU_FREQ) && (NUM_CORES == 1) | ||
808 | ipod_set_cpu_frequency(); | ||
809 | #endif | ||
810 | } | ||
811 | #if (!defined HAVE_ADJUSTABLE_CPU_FREQ) && (NUM_CORES > 1) | ||
812 | else | ||
813 | { | ||
814 | ipod_set_cpu_frequency(); | ||
815 | } | ||
775 | #endif | 816 | #endif |
776 | ipod_init_cache(); | 817 | ipod_init_cache(); |
777 | #endif | 818 | #endif |
@@ -796,10 +837,18 @@ extern void TIMER2(void); | |||
796 | 837 | ||
797 | void irq(void) | 838 | void irq(void) |
798 | { | 839 | { |
799 | if (CPU_INT_STAT & TIMER1_MASK) | 840 | if(CURRENT_CORE == CPU) |
800 | TIMER1(); | 841 | { |
801 | else if (CPU_INT_STAT & TIMER2_MASK) | 842 | if (CPU_INT_STAT & TIMER1_MASK) |
802 | TIMER2(); | 843 | TIMER1(); |
844 | else if (CPU_INT_STAT & TIMER2_MASK) | ||
845 | TIMER2(); | ||
846 | } else { | ||
847 | if (COP_INT_STAT & TIMER1_MASK) | ||
848 | TIMER1(); | ||
849 | else if (COP_INT_STAT & TIMER2_MASK) | ||
850 | TIMER2(); | ||
851 | } | ||
803 | } | 852 | } |
804 | 853 | ||
805 | #endif | 854 | #endif |
@@ -848,29 +897,32 @@ void set_cpu_frequency(long frequency) | |||
848 | { | 897 | { |
849 | unsigned long postmult; | 898 | unsigned long postmult; |
850 | 899 | ||
851 | if (frequency == CPUFREQ_NORMAL) | 900 | if (CURRENT_CORE == CPU) |
852 | postmult = CPUFREQ_NORMAL_MULT; | 901 | { |
853 | else if (frequency == CPUFREQ_MAX) | 902 | if (frequency == CPUFREQ_NORMAL) |
854 | postmult = CPUFREQ_MAX_MULT; | 903 | postmult = CPUFREQ_NORMAL_MULT; |
855 | else | 904 | else if (frequency == CPUFREQ_MAX) |
856 | postmult = CPUFREQ_DEFAULT_MULT; | 905 | postmult = CPUFREQ_MAX_MULT; |
857 | cpu_frequency = frequency; | 906 | else |
907 | postmult = CPUFREQ_DEFAULT_MULT; | ||
908 | cpu_frequency = frequency; | ||
858 | 909 | ||
859 | outl(0x02, 0xcf005008); | 910 | outl(0x02, 0xcf005008); |
860 | outl(0x55, 0xcf00500c); | 911 | outl(0x55, 0xcf00500c); |
861 | outl(0x6000, 0xcf005010); | 912 | outl(0x6000, 0xcf005010); |
862 | 913 | ||
863 | /* Clock frequency = (24/8)*postmult */ | 914 | /* Clock frequency = (24/8)*postmult */ |
864 | outl(8, 0xcf005018); | 915 | outl(8, 0xcf005018); |
865 | outl(postmult, 0xcf00501c); | 916 | outl(postmult, 0xcf00501c); |
866 | 917 | ||
867 | outl(0xe000, 0xcf005010); | 918 | outl(0xe000, 0xcf005010); |
868 | 919 | ||
869 | /* Wait for PLL relock? */ | 920 | /* Wait for PLL relock? */ |
870 | udelay(2000); | 921 | udelay(2000); |
871 | 922 | ||
872 | /* Select PLL as clock source? */ | 923 | /* Select PLL as clock source? */ |
873 | outl(0xa8, 0xcf00500c); | 924 | outl(0xa8, 0xcf00500c); |
925 | } | ||
874 | } | 926 | } |
875 | #elif !defined(BOOTLOADER) | 927 | #elif !defined(BOOTLOADER) |
876 | static void ipod_set_cpu_speed(void) | 928 | static void ipod_set_cpu_speed(void) |
@@ -901,17 +953,20 @@ static void ipod_set_cpu_speed(void) | |||
901 | void system_init(void) | 953 | void system_init(void) |
902 | { | 954 | { |
903 | #ifndef BOOTLOADER | 955 | #ifndef BOOTLOADER |
904 | /* Remap the flash ROM from 0x00000000 to 0x20000000. */ | 956 | if (CURRENT_CORE == CPU) |
905 | MMAP3_LOGICAL = 0x20000000 | 0x3a00; | 957 | { |
906 | MMAP3_PHYSICAL = 0x00000000 | 0x3f84; | 958 | /* Remap the flash ROM from 0x00000000 to 0x20000000. */ |
907 | 959 | MMAP3_LOGICAL = 0x20000000 | 0x3a00; | |
908 | ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc))); | 960 | MMAP3_PHYSICAL = 0x00000000 | 0x3f84; |
909 | outl(-1, 0xcf00101c); | 961 | |
910 | outl(-1, 0xcf001028); | 962 | ipod_hw_rev = (*((volatile unsigned long*)(0x01fffffc))); |
911 | outl(-1, 0xcf001038); | 963 | outl(-1, 0xcf00101c); |
964 | outl(-1, 0xcf001028); | ||
965 | outl(-1, 0xcf001038); | ||
912 | #ifndef HAVE_ADJUSTABLE_CPU_FREQ | 966 | #ifndef HAVE_ADJUSTABLE_CPU_FREQ |
913 | ipod_set_cpu_speed(); | 967 | ipod_set_cpu_speed(); |
914 | #endif | 968 | #endif |
969 | } | ||
915 | ipod_init_cache(); | 970 | ipod_init_cache(); |
916 | #endif | 971 | #endif |
917 | } | 972 | } |