frd66 identified a bug that the frequency declared in nios2_system.h was
wrong, which was the external one that go to the input of in-system PLL.
He submitted a patch to use internal cpu clock.

But the system timer input does not always come from cpu clock. I
refined his patch and look for the real clock input to the system timer.

na_cpu_clock_freq is added to display correct /proc/cpuinfo.

Signed-off-by: Thomas Chou <[EMAIL PROTECTED]>
---
 linux-2.6.x/arch/nios2nommu/kernel/setup.c         |    4 ++--
 .../arch/nios2nommu/scripts/PTF/SystemPTF.pm       |   16 +++++++++++++---
 .../arch/nios2nommu/scripts/gen_nios2_system.h.pl  |    5 +----
 .../scripts/nios2_system.h/altera_avalon_timer.pm  |    6 ++++++
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/linux-2.6.x/arch/nios2nommu/kernel/setup.c 
b/linux-2.6.x/arch/nios2nommu/kernel/setup.c
index f8aa65c..6312c4f 100644
--- a/linux-2.6.x/arch/nios2nommu/kernel/setup.c
+++ b/linux-2.6.x/arch/nios2nommu/kernel/setup.c
@@ -353,7 +353,7 @@ int get_cpuinfo(char * buffer)
     mmu = "none";
     fpu = "none";
 
-    clockfreq = nasys_clock_freq;
+    clockfreq = na_cpu_clock_freq;
 
     return(sprintf(buffer, "CPU:\t\t%s\n"
                   "MMU:\t\t%s\n"
@@ -381,7 +381,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
     mmu = "none";
     fpu = "none";
 
-    clockfreq = nasys_clock_freq;
+    clockfreq = na_cpu_clock_freq;
 
     seq_printf(m, "CPU:\t\t%s\n"
                   "MMU:\t\t%s\n"
diff --git a/linux-2.6.x/arch/nios2nommu/scripts/PTF/SystemPTF.pm 
b/linux-2.6.x/arch/nios2nommu/scripts/PTF/SystemPTF.pm
index 9f44cfe..4ca77df 100644
--- a/linux-2.6.x/arch/nios2nommu/scripts/PTF/SystemPTF.pm
+++ b/linux-2.6.x/arch/nios2nommu/scripts/PTF/SystemPTF.pm
@@ -124,13 +124,23 @@ sub getSlaveModules {
        return sort module_comparison keys (%connected); 
 }
 
+# get the clock frequency of a module
 sub getClockFreq () {
-       my ($self) = @_;
+       my ($self, $name) = @_;
        
+       my $module = $self->{root}->getSection ('MODULE', $name);
+       $module or return;
+       my $sbi = $module->getSection ('SYSTEM_BUILDER_INFO', '');
+       $sbi or return;
+       my $clk_src = $sbi->getAssignment ('Clock_Source');
+       $clk_src or return;
        my $wsa = $self->{root}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
        $wsa or return;
-       
-       my $result = $wsa->getAssignment ('clock_freq');
+       my $clocks = $wsa->getSection ('CLOCKS', '');
+       $clocks or return;
+       my $clock = $clocks->getSection ('CLOCK', $clk_src);
+       $clock or return;
+       my $result = $clock->getAssignment ('frequency');
        return $result;
 }
 
diff --git a/linux-2.6.x/arch/nios2nommu/scripts/gen_nios2_system.h.pl 
b/linux-2.6.x/arch/nios2nommu/scripts/gen_nios2_system.h.pl
index 4394c74..c8c190a 100644
--- a/linux-2.6.x/arch/nios2nommu/scripts/gen_nios2_system.h.pl
+++ b/linux-2.6.x/arch/nios2nommu/scripts/gen_nios2_system.h.pl
@@ -287,11 +287,8 @@ if (!$upload_location || ($upload_location eq 
"flash_kernel")) {
 }
 
 print "\n";
-
-printf ("#define %-33s %30s\n", 
-       ("nasys_clock_freq", $system->getClockFreq()));
 printf ("#define %-33s %30s\n", 
-       ("nasys_clock_freq_1000", int ($system->getClockFreq()) / 1000));
+       ("na_cpu_clock_freq", $system->getClockFreq($target_cpu)));
        
 {      
        my ($reset_location, $reset_offset) = $cpu->getResetLocationOffset();
diff --git 
a/linux-2.6.x/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm 
b/linux-2.6.x/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
index 495ccdc..dc01e4f 100644
--- a/linux-2.6.x/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
+++ b/linux-2.6.x/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
@@ -33,6 +33,12 @@ sub is_module_valid {
        my $fixed_period = $module->getWSAAssignment ('fixed_period');  
 
        if ($fixed_period eq '0') {
+           printf ("\n");
+           printf ("/* system timer input clock frequency */\n");
+           printf ("#define %-33s %30s\n", 
+                   ("nasys_clock_freq", $system->getClockFreq($module_name)));
+           printf ("#define %-33s %30s\n", 
+                   ("nasys_clock_freq_1000", int 
($system->getClockFreq($module_name)) / 1000));
                return 1;
        } else {
                return 0;
-- 
1.5.3.3

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to