📄 1013.frequency.patch
字号:
diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linux-2.6.15.ref/arch/mips/kernel/proc.c linux-2.6.15/arch/mips/kernel/proc.c--- linux-2.6.15.ref/arch/mips/kernel/proc.c 2006-01-25 20:51:10.000000000 -0800+++ linux-2.6.15/arch/mips/kernel/proc.c 2007-07-06 10:25:03.000000000 -0700@@ -111,9 +111,15 @@ current_cpu_data.cputype : CPU_UNKNOWN], (version >> 4) & 0x0f, version & 0x0f, (fp_vers >> 4) & 0x0f, fp_vers & 0x0f);+#ifdef CONFIG_TANGOX+ seq_printf(m, "Initial BogoMIPS\t: %lu.%02lu\n",+ cpu_data[n].udelay_val / (500000/HZ),+ (cpu_data[n].udelay_val / (5000/HZ)) % 100);+#else seq_printf(m, "BogoMIPS\t\t: %lu.%02lu\n", cpu_data[n].udelay_val / (500000/HZ), (cpu_data[n].udelay_val / (5000/HZ)) % 100);+#endif seq_printf(m, "wait instruction\t: %s\n", cpu_wait ? "yes" : "no"); seq_printf(m, "microsecond timers\t: %s\n", cpu_has_counter ? "yes" : "no");@@ -136,6 +142,16 @@ seq_printf(m, fmt, 'D', vced_count); seq_printf(m, fmt, 'I', vcei_count); +#ifdef CONFIG_TANGOX+ {+ extern unsigned long tangox_get_cpuclock(void);+ extern unsigned long tangox_get_sysclock(void);+ extern unsigned long tangox_get_dspclock(void);+ seq_printf(m, "System bus frequency\t: %ld Hz\n", tangox_get_sysclock());+ seq_printf(m, "CPU frequency\t\t: %ld Hz\n", tangox_get_cpuclock());+ seq_printf(m, "DSP frequency\t\t: %ld Hz\n", tangox_get_dspclock());+ }+#endif return 0; } diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linux-2.6.15.ref/arch/mips/kernel/time.c linux-2.6.15/arch/mips/kernel/time.c--- linux-2.6.15.ref/arch/mips/kernel/time.c 2007-07-06 10:20:48.000000000 -0700+++ linux-2.6.15/arch/mips/kernel/time.c 2007-07-06 10:25:03.000000000 -0700@@ -46,6 +46,14 @@ #include <asm/tango3/emhwlib_registers_tango3.h> #endif +#ifdef CONFIG_TANGOX+void reset_timer(unsigned long cpu, unsigned long sys);+extern unsigned long tangox_get_cpuclock(void);+extern unsigned long tangox_get_sysclock(void);+extern unsigned long em8xxx_cpu_frequency;+extern unsigned long em8xxx_sys_frequency;+#endif+ /* * The integer part of the number of usecs per jiffy is taken from tick, * but the fractional part is not recorded, so we calculate it using the@@ -442,6 +450,8 @@ static unsigned long old_xtal = 0; long diff; unsigned long xtal;+ unsigned long cpu_frequency = tangox_get_cpuclock();+ unsigned long sys_frequency = tangox_get_sysclock(); #endif if ((jiffies % HZ) == 0) { /* Update CPU heart beat conunter per second */@@ -464,6 +474,10 @@ } else active = 1; old_xtal = xtal;+ if ((cpu_frequency != em8xxx_cpu_frequency) || (sys_frequency != em8xxx_sys_frequency)) {+ /* Detected CPU/System frequency change */+ reset_timer(cpu_frequency, sys_frequency);+ } #endif #endif @@ -820,3 +834,36 @@ { return (unsigned long long)jiffies*(1000000000/HZ); }++#ifdef CONFIG_TANGOX+/* Called after PLL has been reset */+void reset_timer(unsigned long cpu_freq, unsigned long sys_freq)+{+#ifndef CONFIG_TANGOX_USE_CPU_CLOCK+ extern void reset_cpu_timer0(void);+#endif+ em8xxx_cpu_frequency = cpu_freq;+ em8xxx_sys_frequency = sys_freq;++ mips_hpt_frequency = em8xxx_cpu_frequency / 2;++ /* Calculate cache parameters. */+ cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ;++#ifndef CONFIG_TANGOX_USE_CPU_CLOCK+ reset_cpu_timer0();+#else+ /* sll32_usecs_per_cycle = 10^6 * 2^32 / mips_counter_freq */+ do_div64_32(sll32_usecs_per_cycle,+ 1000000, mips_hpt_frequency / 2,+ mips_hpt_frequency);+#endif++ /* Report the high precision timer rate for a reference. */+ printk("Using %u.%03u MHz high precision timer.\n",+ ((mips_hpt_frequency + 500) / 1000) / 1000,+ ((mips_hpt_frequency + 500) / 1000) % 1000);+}+EXPORT_SYMBOL(reset_timer);+#endif /* CONFIG_TANGOX */+diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linux-2.6.15.ref/arch/mips/pci/pci-tangox.c linux-2.6.15/arch/mips/pci/pci-tangox.c--- linux-2.6.15.ref/arch/mips/pci/pci-tangox.c 2007-07-06 10:20:50.000000000 -0700+++ linux-2.6.15/arch/mips/pci/pci-tangox.c 2007-07-06 10:25:03.000000000 -0700@@ -32,6 +32,8 @@ #include <asm/tango3/tango3_pci.h> #endif +#include <asm/cacheflush.h>+ /* * computed in prom.c */@@ -354,3 +356,24 @@ } } +void tangox_pci_enable(void)+{+ struct pci_bus *bus = tangox_controller.bus;+ struct list_head *list;++ if (pci_active) {+ list_for_each(list, &bus->devices) {+ pci_set_master(pci_dev_b(list));+ }+ }+}++void tangox_flush_cache_all(void)+{+ flush_cache_all();+}++EXPORT_SYMBOL(tangox_pci_shutdown);+EXPORT_SYMBOL(tangox_pci_enable);+EXPORT_SYMBOL(tangox_flush_cache_all);+diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linux-2.6.15.ref/arch/mips/tangox/fctrl/fckernel.c linux-2.6.15/arch/mips/tangox/fctrl/fckernel.c--- linux-2.6.15.ref/arch/mips/tangox/fctrl/fckernel.c 1969-12-31 16:00:00.000000000 -0800+++ linux-2.6.15/arch/mips/tangox/fctrl/fckernel.c 2007-07-06 10:25:03.000000000 -0700@@ -0,0 +1,656 @@++#include <linux/config.h>+#include <linux/init.h>+#include <linux/module.h>+#include <linux/types.h>+#include <linux/delay.h>+#include <linux/etherdevice.h>+#include <linux/interrupt.h>+#include <linux/proc_fs.h>+#include <linux/ctype.h>+#include <asm/tlbflush.h>++#include "lib/fc/fcconfig.h"+#include "lib/freqctrl.h"++#ifdef CONFIG_TANGO2+#define EM86XX_CHIP EM86XX_CHIPID_TANGO2+#include <linux/interrupt.h>+#include <asm/tango2/rmem86xxid.h>+#include <asm/tango2/rmdefs.h>+#include <asm/tango2/emhwlib_dram.h>+#include <asm/tango2/tango2_gbus.h>+#include <asm/tango2/tango2.h>+#include <asm/tango2/tango2api.h>+#include <asm/tango2/memcfg.h>+#elif defined(CONFIG_TANGO3)+#define EM86XX_CHIP EM86XX_CHIPID_TANGO3+#include <linux/interrupt.h>+#include <asm/tango3/rmem86xxid.h>+#include <asm/tango3/rmdefs.h>+#include <asm/tango3/emhwlib_dram.h>+#include <asm/tango3/tango3_gbus.h>+#include <asm/tango3/tango3.h>+#include <asm/tango3/tango3api.h>+#include <asm/tango3/memcfg.h>+#else+#error "Unknown architecture"+#endif++/* The names used in proc_fs */+#define PROC_ROOT "tangoxfreq"+#define PROC_PROFILE "profile"+#define PROC_MUX "mux"+#define PROC_PLL3 "pll3"+#define PROC_PLL2 "pll2"+#define PROC_PLL1 "pll1"+#define PROC_PLL0 "pll0"+#define PROC_FREQ "freq"++#ifdef WITH_INPUT_POLLING+#define PROC_STANDBY "standby"+#ifdef WITH_IR+#define PROC_IR "ir_table"+#endif+#ifdef WITH_FIP+#define PROC_FIP "fip_table"+#endif+#endif++/* Get XENV parameters related to frequency profile */+extern void tangox_get_ps_config(unsigned long *pll3, unsigned long *pll2, unsigned long *pll1, + unsigned long *pll0, unsigned long *mux, unsigned long *d0cfg, unsigned long *d0delay, + unsigned long *d1cfg, unsigned long *d1delay);++#ifdef WITH_INPUT_POLLING+extern void tangox_get_standby_config(unsigned long *pll3, unsigned long *pll2, unsigned long *pll1, + unsigned long *pll0, unsigned long *mux, unsigned long *d0cfg, unsigned long *d0delay, + unsigned long *d1cfg, unsigned long *d1delay);+#endif++extern unsigned long tangox_get_cpuclock(void);+extern unsigned long tangox_get_sysclock(void);+extern unsigned long tangox_get_dspclock(void);+extern unsigned long tangox_get_pllclock(int idx);++static struct freq_profile freq_table[] = {+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "ORIGINAL" }, /* for saving the status when it's been loaded */+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "PS XENV" }, /* for getting the ps status when it's been loaded from XENV */+ { 0x0110009e, 0, 0, 0, 0x301, 0xf21111ba, 0x88888, 0xf21111ba, 0x88888, 0, "SYS/CPU/DSP 80/80/80" }, /* SYS/CPU/DSP: 80/80/80MHz, 2/2.5 */+ { 0x011000c6, 0, 0, 0, 0x701, 0xf21111ba, 0x97777, 0xf21111ba, 0x97777, 0, "SYS/CPU/DSP 100/150/150" }, /* SYS/CPU/DSP: 150/100/150MHz, 2/2.5 */+ { 0x01100108, 0, 0, 0, 0x701, 0xf21111ba, 0x97777, 0xf21111ba, 0x97777, 0, "SYS/CPU/DSP 133/200/200" }, /* SYS/CPU/DSP: 200/133/200MHz, 2/2.5 */+ { 0x0110014a, 0, 0, 0, 0x701, 0xf34111ba, 0xa7777, 0xf34111ba, 0xa7777, 0, "SYS/CPU/DSP 166/250/250" }, /* SYS/CPU/DSP: 250/166/250MHz, 3/4 */+ { 0x01010041, 0, 0, 0, 0x701, 0xf34111ba, 0xa4444, 0xf34111ba, 0xa4444, 0, "SYS/CPU/DSP 200/300/300" }, /* SYS/CPU/DSP: 300/200/300MHz, 3/4 */+};++#ifdef WITH_INPUT_POLLING+static struct freq_profile standby_mode =+// { 0x01010010, 0x202, 0x202, 0x202, 0x301, 0xf21111ba, 0x88888, 0xf21111ba, 0x88888, 1, "54/54/54" }; /* CPU/SYS/DSP: 54/54/54MHz, 2/2.5 PLL3 162MHz */+// { 0x0119006a, 0x202, 0x202, 0x202, 0x1, 0xf21111ba, 0x88888, 0xf21111ba, 0x88888, 1, "54/54/54" }; /* CPU/SYS/DSP: 54/54/54MHz, 2/2.5 PLL3 108MHz */+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "STANDBY XENV" }; /* get the settings from XENV */+#endif++static int profile_idx = 0;+static struct proc_dir_entry *root = NULL, *prof_ent = NULL, *mux_ent = NULL, *pll3_ent = NULL;+static struct proc_dir_entry *pll1_ent = NULL, *pll2_ent = NULL, *pll0_ent = NULL, *freq_ent = NULL;++#ifdef WITH_INPUT_POLLING+static struct proc_dir_entry *standby_ent;+#ifdef WITH_IR+static struct proc_dir_entry *ir_ent = NULL;+#endif+#ifdef WITH_FIP+static struct proc_dir_entry *fip_ent = NULL;+#endif+static unsigned long ir_keys[INPUT_TABLE_SIZE/sizeof(unsigned long)];+static unsigned long fip_keys[INPUT_TABLE_SIZE/sizeof(unsigned long)];+static int ir_key_cnt, fip_key_cnt;+#endif++static const unsigned char ratios_table[12][3] = {+ { 2, 2, 2 },+ { 4, 2, 4 },+ { 3, 2, 3 },+ { 3, 3, 3 },+ { 3, 3, 3 },+ { 3, 2, 3 },+ { 3, 3, 2 },+ { 3, 2, 2 },+ { 4, 4, 4 },+ { 4, 2, 4 },+ { 4, 4, 2 },+ { 4, 2, 2 }+};++static void recalc_frequency(void)+{+ extern void tangox_bmide_calc_speed(void);+ extern void tangox_pbide_calc_speed(void);++#ifdef CONFIG_BLK_DEV_BMIDE_TANGOX+ tangox_bmide_calc_speed();+#endif+#ifdef CONFIG_BLK_DEV_PBIDE_TANGOX+ tangox_pbide_calc_speed();+#endif++ /* TODO: may need to re-adjust the CDs */+}++static int change_profile(const char *str)+{+ int prof = simple_strtol(str, NULL, 10);+ int ret = 0;++ if ((prof < 0) || (prof >= (sizeof(freq_table)/sizeof(struct freq_profile)))) + return -EINVAL;++ for (; prof < sizeof(freq_table)/sizeof(struct freq_profile); prof++) {+ /* Look for defined profile */+ if (freq_table[prof].pll3 != 0)+ break;+ }++ /* No valid profile found, use original one */+ if (prof >= (sizeof(freq_table)/sizeof(struct freq_profile)))+ prof = 0; ++ if (profile_idx == prof)+ return 0;++ profile_idx = prof;++#ifdef WITH_INPUT_POLLING+ ret = set_freq_profile(&freq_table[prof], NULL, NULL, NULL, NULL);+#else+ ret = set_freq_profile(&freq_table[prof]);+#endif++ recalc_frequency();++ return ret;+}++static int change_mux(const char *mux_str)+{+ struct freq_profile freq_prof;+ int mux = simple_strtol(mux_str, NULL, 10);+ int ret = 0;++ if ((mux < 0) || (mux > 11))+ return -EINVAL;++ freq_prof.mux = (gbus_readl(REG_BASE_system_block+SYS_sysclk_mux) & 0xfffff0ff) | (mux << 8);+ freq_prof.d0cfg = gbus_readl(REG_BASE_dram_controller_0+DRAM_dunit_cfg);+ freq_prof.d0delays = gbus_readl(REG_BASE_dram_controller_0+DRAM_dunit_delay0_ctrl);+ freq_prof.d1cfg = gbus_readl(REG_BASE_dram_controller_1+DRAM_dunit_cfg);+ freq_prof.d1delays = gbus_readl(REG_BASE_dram_controller_1+DRAM_dunit_delay0_ctrl);+ freq_prof.pll3 = gbus_readl(REG_BASE_system_block+SYS_clkgen3_pll);+ freq_prof.pll2 = freq_prof.pll1 = freq_prof.pll0 = 0;+ freq_prof.standby = 0;++ if (freq_prof.mux != gbus_readl(REG_BASE_system_block+SYS_sysclk_mux))+ profile_idx = -1;++#ifdef WITH_INPUT_POLLING+ ret = set_freq_profile(&freq_prof, NULL, NULL, NULL, NULL);+#else+ ret = set_freq_profile(&freq_prof);+#endif++ recalc_frequency();++ return ret;+}++static int pllx_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)+{+ char buf[64];+ unsigned long freq;+ struct freq_profile freq_prof;+ int idx = (int)data;++ if (count > ARRAY_SIZE(buf) - 1)+ count = ARRAY_SIZE(buf) - 1;+ if (copy_from_user(buf, buffer, count))+ return -EFAULT;++ buf[count] = '\0';+ freq = simple_strtol(buf, NULL, 10);++ freq_prof.mux = gbus_readl(REG_BASE_system_block+SYS_sysclk_mux);+ freq_prof.d0cfg = gbus_readl(REG_BASE_dram_controller_0+DRAM_dunit_cfg);+ freq_prof.d0delays = gbus_readl(REG_BASE_dram_controller_0+DRAM_dunit_delay0_ctrl);+ freq_prof.d1cfg = gbus_readl(REG_BASE_dram_controller_1+DRAM_dunit_cfg);+ freq_prof.d1delays = gbus_readl(REG_BASE_dram_controller_1+DRAM_dunit_delay0_ctrl);+ freq_prof.standby = 0;+ freq_prof.pll3 = gbus_readl(REG_BASE_system_block+SYS_clkgen3_pll);+ freq_prof.pll2 = gbus_readl(REG_BASE_system_block+SYS_clkgen2_pll);+ freq_prof.pll1 = gbus_readl(REG_BASE_system_block+SYS_clkgen1_pll);+ freq_prof.pll0 = gbus_readl(REG_BASE_system_block+SYS_clkgen0_pll);++ if (idx == 3) {+ freq_prof.pll3 = frequency_to_pll(freq, 1);+ } else if (idx == 2) {+ freq_prof.pll2 = frequency_to_pll(freq, 1);+ } else if (idx == 1) {+ freq_prof.pll1 = frequency_to_pll(freq, 1);+ } else if (idx == 0) {+ freq_prof.pll0 = frequency_to_pll(freq, 1);+ }++ profile_idx = -1;+#ifdef WITH_INPUT_POLLING+ set_freq_profile(&freq_prof, NULL, NULL, NULL, NULL);+#else+ set_freq_profile(&freq_prof);+#endif++ recalc_frequency();++ return count;+}++static int pllx_info_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)+{+ int ret = 0;+ int idx = (int)data;++ ret = sprintf(page + off, "PLL%d: %ldHz\n", idx, tangox_get_pllclock(idx));+ *eof = 1;+ return ret;+}++static int freq_info_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)+{+ int ret = 0;+ int i;+ for (i = 0; i < 4; i++) {+ ret += sprintf(page + off + ret, "PLL%d: %ldHz\n", i, tangox_get_pllclock(i));+ }+ ret += sprintf(page + off + ret, "SYS: %ldHz\n", tangox_get_sysclock());+ ret += sprintf(page + off + ret, "CPU: %ldHz\n", tangox_get_cpuclock());+ ret += sprintf(page + off + ret, "DSP: %ldHz\n", tangox_get_dspclock());+ *eof = 1;+ return ret;+}++static int profile_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)+{+ char buf[16];++ if (count > ARRAY_SIZE(buf) - 1)+ count = ARRAY_SIZE(buf) - 1;+ if (copy_from_user(buf, buffer, count))+ return -EFAULT;++ buf[count] = '\0';++ change_profile(buf);++ return count;+}++static int profile_info_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)+{+ int ret = 0;+ int i;++ for (i = 0; i < (sizeof(freq_table)/sizeof(struct freq_profile)); i++) {+ if (freq_table[i].pll3 == 0)+ continue;+ ret += sprintf(page + off + ret, "%c %d: %s\n", (profile_idx == i) ? '*' : ' ', + i, freq_table[i].desc);+ }+ *eof = 1;+ return ret;+}++static int mux_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -