⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1013.frequency.patch

📁 sm86xx内核源包括补丁( GPL )的
💻 PATCH
📖 第 1 页 / 共 4 页
字号:
+{+	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_mux(buf);++	return count;+}++static int mux_info_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)+{+	int ret = 0, i;+	unsigned long mux = (gbus_readl(REG_BASE_system_block+SYS_sysclk_mux) >> 8) & 0xf;+	unsigned long premux = gbus_readl(REG_BASE_system_block+SYS_sysclk_premux);+	+	ret = sprintf(page + off, "PLL%ld: %ldHz\n", premux & 3, tangox_get_pllclock(premux & 3));+	for (i = 0; i < 12; i++) {+		ret += sprintf(page + off + ret, "%c %d (SYS/CPU/DSP: %d/%d/%d)\n",+				(i == mux) ? '*' : ' ', i,+				ratios_table[i][0], ratios_table[i][1], ratios_table[i][2]);+	}+	*eof = 1;+	return ret;+}++#ifdef WITH_INPUT_POLLING+static int standby_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)+{+	char buf[16];+	unsigned long elapse, ret_key;+	unsigned long *ir_table, *fip_table;++	if (count > ARRAY_SIZE(buf) - 1)+		count = ARRAY_SIZE(buf) - 1;+	if (copy_from_user(buf, buffer, count))+		return -EFAULT;++	if (standby_mode.pll3 == 0) { /* not yet setting up */+		printk("standby mode parameters not set up yet.\n");+		return -EINVAL;+	}++	buf[count] = '\0';++#ifdef WITH_IR+	ir_table = (ir_key_cnt ? ir_keys : NULL);+#else+	ir_table = NULL;+#endif+#ifdef WITH_FIP+	fip_table = (fip_key_cnt ? fip_keys : NULL);+#else+	fip_table = NULL;+#endif++	if (strncmp("standby", buf, strlen("standby")) == 0) {+		printk("Entering standby mode ...\n");+		set_freq_profile(&standby_mode, &elapse, &ret_key, ir_table, fip_table);+		jiffies_64 += ((elapse * HZ) / 1000); /* elaspe in msec so we adjust it accordingly */ +		printk("Returned key 0x%08lx, time elapse %ld jiffies.\n", ret_key, (elapse * HZ) / 1000);+	//	recalc_frequency();+	}++	return count;+}++#if defined(WITH_IR) || defined(WITH_FIP)+static const char *hex2string(unsigned long *hex, const char *src_ptr)+{+	unsigned long res = 0;+	const char *src = src_ptr;++	for (; isxdigit(*src); src++) {+		if (isdigit(*src))+			res = res * 16 + ((*src) - '0');+		else+			res = res * 16 + (__toupper(*src) - 'A' + 10);+	}+	*hex = res;+	return(src);+}++static const char *dec2string(unsigned long *dec, const char *src_ptr)+{+	unsigned long res = 0;+	const char *src = src_ptr;++	for (; isdigit(*src); src++) {+		res = res * 10 + ((*src) - '0');+	}+	*dec = res;+	return(src);+}+#endif++#ifdef WITH_IR+static int ir_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)+{+	int i;+	unsigned long cnt;+	const char *ptr = buffer, *end = buffer + count;++	memset(ir_keys, 0, INPUT_TABLE_SIZE);+	ir_key_cnt = 0;++	/* Parse the values */+	for (cnt = i = 0; (i < INPUT_TABLE_SIZE/sizeof(unsigned long)) && (cnt < count); i++) {+		for (; (!isdigit(*ptr)) && (ptr < end); ptr++);  /* skip leading unwanted stuff */+		if (ptr >= end)+			break; /* no more */+		else if ((*ptr == '0') && (__toupper(*(ptr + 1)) == 'X')) +			ptr = hex2string(&ir_keys[i], ptr + 2);+		else+			ptr = dec2string(&ir_keys[i], ptr);+	}+	ir_key_cnt = i;+	return(count);+}++static int ir_info_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)+{+	int i, ret = 0;+	for (i = 0; i < INPUT_TABLE_SIZE/sizeof(unsigned long); i++) {+		if (ir_keys[i]) +			ret += sprintf(page + off + ret, "0x%lx ", ir_keys[i]);+	}+	if (ret)+		ret += sprintf(page + off + ret, "\n");+	else	+		ret += sprintf(page + off + ret, "No IR key defined.\n");+	*eof = 1;+	return(ret);+}+#endif+#ifdef WITH_FIP+static int fip_info_write_proc(struct file *file, const char __user *buffer, unsigned long count, void *data)+{+	int i;+	unsigned long cnt;+	const char *ptr = buffer, *end = buffer + count;++	memset(fip_keys, 0, INPUT_TABLE_SIZE);+	fip_key_cnt = 0;++	/* Parse the values */+	for (cnt = i = 0; (i < INPUT_TABLE_SIZE/sizeof(unsigned long)) && (cnt < count); i++) {+		for (; (!isdigit(*ptr)) && (ptr < end); ptr++);  /* skip leading unwanted stuff */+		if (ptr >= end)+			break; /* no more */+		else if ((*ptr == '0') && (__toupper(*(ptr + 1)) == 'X')) +			ptr = hex2string(&fip_keys[i], ptr + 2);+		else+			ptr = dec2string(&fip_keys[i], ptr);+	}+	fip_key_cnt = i;+	return(count);+}++static int fip_info_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)+{+	int i, ret = 0;+	for (i = 0; i < INPUT_TABLE_SIZE/sizeof(unsigned long); i++) {+		if (fip_keys[i]) +			ret += sprintf(page + off + ret, "0x%lx ", fip_keys[i]);+	}+	if (ret)+		ret += sprintf(page + off + ret, "\n");+	else	+		ret += sprintf(page + off + ret, "No FIP key defined.\n");+	*eof = 1;+	return(ret);+}+#endif+#endif++static int tangox_freq_ctrl_init(void) +{+	int i;++#ifdef WITH_INPUT_POLLING+	memset(ir_keys, 0, INPUT_TABLE_SIZE);+	memset(fip_keys, 0, INPUT_TABLE_SIZE);+	ir_key_cnt = fip_key_cnt = 0;+#endif++	freq_table[0].pll3 = gbus_readl(REG_BASE_system_block+SYS_clkgen3_pll);+	freq_table[0].pll2 = gbus_readl(REG_BASE_system_block+SYS_clkgen2_pll);+	freq_table[0].pll1 = gbus_readl(REG_BASE_system_block+SYS_clkgen1_pll);+	freq_table[0].pll0 = gbus_readl(REG_BASE_system_block+SYS_clkgen0_pll);+	freq_table[0].mux = gbus_readl(REG_BASE_system_block+SYS_sysclk_mux);+	freq_table[0].d0cfg = gbus_readl(REG_BASE_dram_controller_0+DRAM_dunit_cfg);+	freq_table[0].d0delays = gbus_readl(REG_BASE_dram_controller_0+DRAM_dunit_delay0_ctrl);+	freq_table[0].d1cfg = gbus_readl(REG_BASE_dram_controller_1+DRAM_dunit_cfg);+	freq_table[0].d1delays = gbus_readl(REG_BASE_dram_controller_1+DRAM_dunit_delay0_ctrl);++	tangox_get_ps_config(&freq_table[1].pll3, &freq_table[1].pll2, &freq_table[1].pll1, +			&freq_table[1].pll0, &freq_table[1].mux, &freq_table[1].d0cfg, +			&freq_table[1].d0delays, &freq_table[1].d1cfg, &freq_table[1].d1delays);++#ifdef WITH_INPUT_POLLING+	tangox_get_standby_config(&standby_mode.pll3, &standby_mode.pll2, &standby_mode.pll1, +			&standby_mode.pll0, &standby_mode.mux, &standby_mode.d0cfg, +			&standby_mode.d0delays, &standby_mode.d1cfg, &standby_mode.d1delays);+#endif++	for (i = 2; i < (sizeof(freq_table)/sizeof(struct freq_profile)); i++) {+		freq_table[i].d0cfg = (freq_table[i].d0cfg & 0x0fffffff) | (freq_table[0].d0cfg & 0xf0000000);+		freq_table[i].d1cfg = (freq_table[i].d1cfg & 0x0fffffff) | (freq_table[0].d1cfg & 0xf0000000);+	}++	if ((root = proc_mkdir(PROC_ROOT, NULL)) == NULL)+		return -EINVAL;++	if ((prof_ent = create_proc_entry(PROC_PROFILE, S_IRUGO | S_IWUGO, root)) == NULL) +		return -EINVAL;+	else {+		prof_ent->read_proc = profile_info_read_proc;+		prof_ent->write_proc = profile_info_write_proc;+	}++	if ((mux_ent = create_proc_entry(PROC_MUX, S_IRUGO | S_IWUGO, root)) == NULL) +		return -EINVAL;+	else {+		mux_ent->read_proc = mux_info_read_proc;+		mux_ent->write_proc = mux_info_write_proc;+	}++	if ((freq_ent = create_proc_entry(PROC_FREQ, S_IRUGO, root)) == NULL) +		return -EINVAL;+	else {+		freq_ent->read_proc = freq_info_read_proc;+	}++	if ((pll3_ent = create_proc_entry(PROC_PLL3, S_IRUGO | S_IWUGO, root)) == NULL) +		return -EINVAL;+	else {+		pll3_ent->read_proc = pllx_info_read_proc;+		pll3_ent->write_proc = pllx_info_write_proc;+		pll3_ent->data = (void *)3;+	}++	if ((pll2_ent = create_proc_entry(PROC_PLL2, S_IRUGO | S_IWUGO, root)) == NULL) +		return -EINVAL;+	else {+		pll2_ent->read_proc = pllx_info_read_proc;+		pll2_ent->write_proc = pllx_info_write_proc;+		pll2_ent->data = (void *)2;+	}++	if ((pll1_ent = create_proc_entry(PROC_PLL1, S_IRUGO | S_IWUGO, root)) == NULL) +		return -EINVAL;+	else {+		pll1_ent->read_proc = pllx_info_read_proc;+		pll1_ent->write_proc = pllx_info_write_proc;+		pll1_ent->data = (void *)1;+	}++	if ((pll0_ent = create_proc_entry(PROC_PLL0, S_IRUGO | S_IWUGO, root)) == NULL) +		return -EINVAL;+	else {+		pll0_ent->read_proc = pllx_info_read_proc;+		pll0_ent->write_proc = pllx_info_write_proc;+		pll0_ent->data = (void *)0;+	}++#ifdef WITH_INPUT_POLLING+	if ((standby_ent = create_proc_entry(PROC_STANDBY, S_IWUGO, root)) == NULL) +		return -EINVAL;+	else +		standby_ent->write_proc = standby_info_write_proc;+#ifdef WITH_IR+	if (tangox_ir_enabled()) {+		if ((ir_ent = create_proc_entry(PROC_IR, S_IRUGO | S_IWUGO, root)) == NULL) +			return -EINVAL;+		else {	+			ir_ent->write_proc = ir_info_write_proc;+			ir_ent->read_proc = ir_info_read_proc;+		}+	}+#endif+#ifdef WITH_FIP+	if (tangox_fip_enabled()) {+		if ((fip_ent = create_proc_entry(PROC_FIP, S_IRUGO | S_IWUGO, root)) == NULL) +			return -EINVAL;+		else {+			fip_ent->write_proc = fip_info_write_proc;+			fip_ent->read_proc = fip_info_read_proc;+		}+	}+#endif+#endif++	printk("tangox frequency scaling module installed");+#ifdef WITH_INPUT_POLLING+	printk(", (standby mode supported)");+#endif+	printk(".\n");+	return 0;+}++static void tangox_freq_ctrl_exit(void) /* Removes module from kernel */+{+	if (root) {+		if (prof_ent)+			remove_proc_entry(PROC_PROFILE, root);+		if (mux_ent)+			remove_proc_entry(PROC_MUX, root);+		if (pll3_ent)+			remove_proc_entry(PROC_PLL3, root);+		if (pll2_ent)+			remove_proc_entry(PROC_PLL2, root);+		if (pll1_ent)+			remove_proc_entry(PROC_PLL1, root);+		if (pll0_ent)+			remove_proc_entry(PROC_PLL0, root);+		if (freq_ent)+			remove_proc_entry(PROC_FREQ, root);+#ifdef WITH_INPUT_POLLING+		if (standby_ent)+			remove_proc_entry(PROC_STANDBY, root);+#ifdef WITH_IR+		if (ir_ent)+			remove_proc_entry(PROC_IR, root);+#endif+#ifdef WITH_FIP+		if (fip_ent)+			remove_proc_entry(PROC_FIP, root);+#endif+#endif+		remove_proc_entry(PROC_ROOT, NULL);+	}+	printk("tangox: frequency scaling module unloaded.\n");+}++module_init(tangox_freq_ctrl_init);+module_exit(tangox_freq_ctrl_exit);++MODULE_DESCRIPTION("SMP863x/SMP865x frequency scaling driver");+MODULE_AUTHOR("Craig Qu/YH Lin");+MODULE_LICENSE("GPL");+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/lib/fc/binout.c linux-2.6.15/arch/mips/tangox/fctrl/lib/fc/binout.c--- linux-2.6.15.ref/arch/mips/tangox/fctrl/lib/fc/binout.c	1969-12-31 16:00:00.000000000 -0800+++ linux-2.6.15/arch/mips/tangox/fctrl/lib/fc/binout.c	2007-07-06 10:25:03.000000000 -0700@@ -0,0 +1,39 @@++/*****************************************+ *  Copyright 漏 2001-2004+ *  Sigma Designs, Inc. All Rights Reserved+ *  Proprietary and Confidential+ ******************************************/++/* Utility program to turn a binary file into a C header file */+#include <stdio.h>+#include <stdlib.h>+#include <unistd.h>+#include <fcntl.h>++static const char *vname = "binout"; /* Default variable name */++int main(int argc, char *argv[])+{+	int cnt = 0, fno = 0;+	unsigned char c;++	if ((fno = open(argv[1], O_RDONLY)) < 0)+		return(-1);+	else if ((argc == 3) && (argv[2] != NULL))+		vname = argv[2];++	printf("static const char %s[] = {\n", vname);+	+	while(read(fno, &c, sizeof(unsigned char)) == sizeof(unsigned char)) {+		if ((cnt > 0) && ((cnt % 16) == 0))+			printf("\n");+		printf("0x%02x,", c);+		cnt++;+	}+	printf("};\n");++	close(fno);+	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/tangox/fctrl/lib/fc/eth.c linux-2.6.15/arch/mips/tangox/fctrl/lib/fc/eth.c--- linux-2.6.15.ref/arch/mips/tangox/fctrl/lib/fc/eth.c	1969-12-31 16:00:00.000000000 -0800+++ linux-2.6.15/arch/mips/tangox/fctrl/lib/fc/eth.c	2007-07-06 10:25:03.000000000 -0700@@ -0,0 +1,91 @@++#include <linux/config.h>++#ifdef CONFIG_TANGO2+#include <asm/tango2/emhwlib_registers_tango2.h>+#include <asm/tango2/emhwlib_dram_tango2.h>+#include <asm/tango2/emhwlib_lram.h>+#elif defined(CONFIG_TANGO3)+#include <asm/tango3/emhwlib_registers_tango3.h>+#include <asm/tango3/emhwlib_dram_tango3.h>+#include <asm/tango2/emhwlib_lram.h>+#endif++#define KSEG1ADDR(x)            (0xa0000000|(x))++#define __sync()				\+	__asm__ __volatile__(			\+		".set	push\n\t"		\+		".set	noreorder\n\t"		\+		".set	mips2\n\t"		\+		"sync\n\t"			\+		".set	pop"			\+		: /* no output */		\+		: /* no input */		\+		: "memory")++#define __fast_iob()				\+	__asm__ __volatile__(			\+		".set	push\n\t"		\+		".set	noreorder\n\t"		\+		"lw	$0,%0\n\t"		\+		"nop\n\t"			\+		".set	pop"			\+		: /* no output */		\+		: "m" (*(int *)0xa0000000)	\+		: "memory")++#define fast_iob()				\+	do {					\+		__sync();			\+		__fast_iob();			\+	} while (0)++#define WOL_CTRL   0x602c++extern void uart_putc(const char c);+extern void uart_puts(const char *s);+extern void udelay(unsigned usec);++static unsigned long wol_ctrl = 0;++int eth_open(void)+{+#ifdef FC_DEBUG+	uart_puts("Listening for WOL packet.\n");+#endif+	wol_ctrl = *((volatile unsigned long *)KSEG1ADDR(REG_BASE_host_interface + WOL_CTRL));+	*((volatile unsigned long *)KSEG1ADDR(REG_BASE_host_interface + WOL_CTRL)) = 6;+	fast_iob();+	return(0);+}++int eth_close(void)+{+	*((volatile unsigned long *)KSEG1ADDR(REG_BASE_host_interface + WOL_CTRL)) = 0x60;+	fast_iob();+	*((volatile unsigned long *)KSEG1ADDR(REG_BASE_host_interface + WOL_CTRL)) = wol_ctrl;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -