[FS#1054] Fix MediaTek MT7621 CPU Frequency Detection

LEDE Bugs lede-bugs at lists.infradead.org
Tue Oct 10 21:19:35 PDT 2017


A new Flyspray task has been opened.  Details are below. 

User who did this - Derick Qiu (qsmcomp) 

Attached to Project - LEDE Project
Summary - Fix MediaTek MT7621 CPU Frequency Detection
Task Type - Bug Report
Category - Kernel
Status - Unconfirmed
Assigned To - 
Operating System - All
Severity - Low
Priority - Very Low
Reported Version - Trunk
Due in Version - Undecided
Due Date - Undecided
Details - diff -ruNd a/arch/mips/ralink/mt7621.c b/arch/mips/ralink/mt7621.c
--- a/arch/mips/ralink/mt7621.c	2017-10-10 16:14:14.828882000 +0800
+++ b/arch/mips/ralink/mt7621.c	2017-10-10 19:56:09.535911838 +0800
@@ -32,6 +32,8 @@
 #define SYSC_REG_CUR_CLK_STS	0x44
 #define CPU_CLK_SEL		(BIT(30) | BIT(31))
 
+#define MEMC_REG_BASE		0x5000
+
 #define MT7621_GPIO_MODE_UART1		1
 #define MT7621_GPIO_MODE_I2C		2
 #define MT7621_GPIO_MODE_UART3_MASK	0x3
@@ -128,7 +130,7 @@
 	int fbdiv = 0;
 	u32 clk_sts, syscfg;
 	u8 clk_sel = 0, xtal_mode;
-	u32 cpu_clk;
+	u32 cpu_clk, cpu_reg;
 
 	if ((rt_sysc_r32(SYSC_REG_CPLL_CLKCFG0) & CPU_CLK_SEL) != 0)
 		clk_sel = 1;
@@ -142,18 +144,25 @@
 		break;
 
 	case 1:
-		fbdiv = ((rt_sysc_r32(0x648) >> 4) & 0x7F) + 1;
+		cpu_reg = rt_sysc_r32(MEMC_REG_BASE + 0x648);
+		fbdiv = ((cpu_reg >> 4) & 0x7F) + 1;
 		syscfg = rt_sysc_r32(SYSC_REG_SYSCFG);
 		xtal_mode = (syscfg >> 6) & 0x7;
 		if(xtal_mode >= 6) { //25Mhz Xtal
 			cpu_clk = 25 * fbdiv * 1000 * 1000;
-		} else if(xtal_mode >=3) { //40Mhz Xtal
-			cpu_clk = 40 * fbdiv * 1000 * 1000;
+		} else if(xtal_mode >= 3) { //40Mhz Xtal
+			cpu_clk = 20 * fbdiv * 1000 * 1000;
 		} else { // 20Mhz Xtal
 			cpu_clk = 20 * fbdiv * 1000 * 1000;
 		}
 		break;
 	}
+
+#define RFMT(label)	label "%u.%03uMHz. "
+#define RINT(x)		((x) / 1000000)
+#define RFRAC(x)	(((x) / 1000) % 1000)
+	pr_info(RFMT("CPU frequency: "),
+		 RINT(cpu_clk), RFRAC(cpu_clk));
 }
 
 void __init ralink_of_remap(void)

 

More information can be found at the following URL:
https://bugs.lede-project.org/index.php?do=details&task_id=1054



More information about the lede-bugs mailing list