Skip to contentSkip to conversation

addition of clocks command for davinci

PATCH New nagabhushana.netagunte at ti.com 2 participants 7 messages Sep 17, 2011 – Oct 6, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover addition of clocks command for davinci

From: Nagabhushana Netagunte <[email protected]>

This patch series adds new command - 'clocks' for davinci family of SOCs. The command prints CPU, DSP core frequencies and DDR frequency. Also, support for printing frequency info during u-boot initialization is removed as it will delay u-boot coming up.

Nagabhushana Netagunte (5):
davinci : move clock related functions to new file
davinci: remove macro CONFIG_DISPLAY_CPUINFO
davinci: add clocks command
dm365: add support to print cpu clock information
da8xx: print ARM and DDR frequency from u-boot

 arch/arm/cpu/arm926ejs/davinci/Makefile      |    2 +-
 arch/arm/cpu/arm926ejs/davinci/cpu.c         |  173 ------------------
 arch/arm/cpu/arm926ejs/davinci/speed.c       |  243 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-davinci/hardware.h |   11 ++
 include/configs/davinci_dm355evm.h           |    1 -
 include/configs/davinci_dm355leopard.h       |    1 -
 include/configs/davinci_dm6467evm.h          |    1 -
 include/configs/davinci_dvevm.h              |    1 -
 include/configs/davinci_schmoogie.h          |    1 -
 include/configs/davinci_sffsdr.h             |    1 -
 include/configs/davinci_sonata.h             |    1 -
 11 files changed, 255 insertions(+), 181 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/speed.c
#1 lore raw

PATCH 1/5 davinci : move clock related functions to new file

From: Nagabhushana Netagunte <[email protected]>

move the functions related to clock from cpu.c to the new file speed.c.

---
 arch/arm/cpu/arm926ejs/davinci/Makefile |    2 +-
 arch/arm/cpu/arm926ejs/davinci/cpu.c    |  173 ---------------------------
 arch/arm/cpu/arm926ejs/davinci/speed.c  |  196 +++++++++++++++++++++++++++++++
 3 files changed, 197 insertions(+), 174 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/speed.c
arch/arm/cpu/arm926ejs/davinci/Makefile +1 -1
index 3183e6a..5630228 100644
@@ -27,7 +27,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(SOC).o
 
-COBJS-y				+= cpu.o timer.o psc.o
+COBJS-y				+= cpu.o timer.o psc.o speed.o
 COBJS-$(CONFIG_SOC_DM355)	+= dm355.o
 COBJS-$(CONFIG_SOC_DM365)	+= dm365.o
 COBJS-$(CONFIG_SOC_DM644X)	+= dm644x.o
arch/arm/cpu/arm926ejs/davinci/cpu.c +0 -173

179 lines not on this page · raw message

arch/arm/cpu/arm926ejs/davinci/speed.c new file +196 -0

196 lines not on this page · raw message

Signature · 1 line
1.6.2.4
#2 lore raw

PATCH 1/5 davinci : move clock related functions to new file

Dear nagabhushana.netagunte at ti.com,

Quoted 5 lines · In message <[email protected]>…

From: Nagabhushana Netagunte <[email protected]>

move the functions related to clock from cpu.c to the new file speed.c.

Quoted 7 lines
---
 arch/arm/cpu/arm926ejs/davinci/Makefile |    2 +-
 arch/arm/cpu/arm926ejs/davinci/cpu.c    |  173 ---------------------------
 arch/arm/cpu/arm926ejs/davinci/speed.c  |  196 +++++++++++++++++++++++++++++++
 3 files changed, 197 insertions(+), 174 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/speed.c

Checkpatch says:

total: 0 errors, 6 warnings, 383 lines checked

Please clean up and resubmit. Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race has one really effective weapon, and that is laughter.
                                                         - Mark Twain
#3 lore raw

PATCH 2/5 davinci: remove macro CONFIG_DISPLAY_CPUINFO

In reply to nagabhushana.netagunte at ti.com

From: Nagabhushana Netagunte <[email protected]>

remove the macro CONFIG_DISPLAY_CPUINFO as it is no longer required. This is because clock info will be printed as part 'clocks' command.

---
 arch/arm/cpu/arm926ejs/davinci/speed.c |    2 --
 include/configs/davinci_dm355evm.h     |    1 -
 include/configs/davinci_dm355leopard.h |    1 -
 include/configs/davinci_dm6467evm.h    |    1 -
 include/configs/davinci_dvevm.h        |    1 -
 include/configs/davinci_schmoogie.h    |    1 -
 include/configs/davinci_sffsdr.h       |    1 -
 include/configs/davinci_sonata.h       |    1 -
 8 files changed, 0 insertions(+), 9 deletions(-)
arch/arm/cpu/arm926ejs/davinci/speed.c +0 -2
index 9dace9e..7d2a6bd 100644
@@ -116,7 +116,6 @@ out:
 }
 #endif /* CONFIG_SOC_DA8XX */
 
-#ifdef CONFIG_DISPLAY_CPUINFO
 
 static unsigned pll_div(volatile void *pllbase, unsigned offset)
 {
@@ -193,4 +192,3 @@ unsigned int davinci_arm_clk_get()
 	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV) * 1000000;
 }
 #endif
-#endif
include/configs/davinci_dm355evm.h +0 -1
index 56d0ac9..0cfc8a5 100644
@@ -26,7 +26,6 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT	/* U-Boot is a 3rd stage loader */
 #define CONFIG_SYS_NO_FLASH		/* that is, no *NOR* flash */
 #define CONFIG_SYS_CONSOLE_INFO_QUIET
-#define CONFIG_DISPLAY_CPUINFO
 
 /* SoC Configuration */
 #define CONFIG_ARM926EJS				/* arm926ejs CPU */
include/configs/davinci_dm355leopard.h +0 -1
index b44b2ea..cbf01cb 100644
@@ -25,7 +25,6 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT	/* U-Boot is a 3rd stage loader */
 #define CONFIG_SYS_NO_FLASH		/* that is, no *NOR* flash */
 #define CONFIG_SYS_CONSOLE_INFO_QUIET
-#define CONFIG_DISPLAY_CPUINFO
 
 /* SoC Configuration */
 #define CONFIG_ARM926EJS				/* arm926ejs CPU */
include/configs/davinci_dm6467evm.h +0 -1
index a0a30f5..1fc3544 100644
@@ -22,7 +22,6 @@
 
 /* Spectrum Digital TMS320DM6467 EVM board */
 #define DAVINCI_DM6467EVM
-#define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_SYS_USE_NAND
 #define CONFIG_SYS_NAND_SMALLPAGE
 
include/configs/davinci_dvevm.h +0 -1
index 086a2d7..2e56501 100644
@@ -51,7 +51,6 @@
 #define DV_EVM
 #define CONFIG_SYS_NAND_SMALLPAGE
 #define CONFIG_SYS_USE_NAND
-#define CONFIG_DISPLAY_CPUINFO
 /*===================*/
 /* SoC Configuration */
 /*===================*/
include/configs/davinci_schmoogie.h +0 -1
index 5cc8bc0..29a3db7 100644
@@ -26,7 +26,6 @@
 #define SCHMOOGIE
 #define CONFIG_SYS_NAND_LARGEPAGE
 #define CONFIG_SYS_USE_NAND
-#define CONFIG_DISPLAY_CPUINFO
 /*===================*/
 /* SoC Configuration */
 /*===================*/
include/configs/davinci_sffsdr.h +0 -1
index 307b9f2..3c1ff28 100644
@@ -28,7 +28,6 @@
 #define CONFIG_SYS_NAND_LARGEPAGE
 #define CONFIG_SYS_USE_NAND
 #define CONFIG_SYS_USE_DSPLINK		/* don't power up the DSP. */
-#define CONFIG_DISPLAY_CPUINFO
 /* SoC Configuration */
 #define CONFIG_ARM926EJS			/* arm926ejs CPU core */
 #define CONFIG_SYS_TIMERBASE		0x01c21400	/* use timer 0 */
include/configs/davinci_sonata.h +0 -1
index 2336129..00b1068 100644
@@ -51,7 +51,6 @@
 #define SONATA_BOARD
 #define CONFIG_SYS_NAND_SMALLPAGE
 #define CONFIG_SYS_USE_NOR
-#define CONFIG_DISPLAY_CPUINFO
 /*===================*/
 /* SoC Configuration */
 /*===================*/
Signature · 1 line
1.6.2.4
#4 lore raw

PATCH 3/5 davinci: add clocks command

In reply to nagabhushana.netagunte at ti.com

From: Nagabhushana Netagunte <[email protected]>

add 'clocks' command to print various clock frequency info found in SOC such as ARM core frequency, DSP core frequency and DDR frequency.

---
 arch/arm/cpu/arm926ejs/davinci/speed.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
arch/arm/cpu/arm926ejs/davinci/speed.c +18 -8
index 7d2a6bd..ebcd212 100644
@@ -20,9 +20,11 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  * MA 02111-1307 USA
  */
-
+#include <common.h>
+#include <netdev.h>
 #include <asm/arch/hardware.h>
 #include <asm/io.h>
+#include <command.h>
 
 /* offsets from PLL controller base */
 #define PLLC_PLLCTL	0x100
@@ -166,7 +168,15 @@ static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
 	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
 }
 
-int print_cpuinfo(void)
+#ifdef DAVINCI_DM6467EVM
+unsigned int davinci_arm_clk_get()
+{
+	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV) * 1000000;
+}
+#endif
+
+int showclocks(cmd_tbl_t *cmdtp,
+	int flag, int argc, char * const argv[])
 {
 	/* REVISIT fetch and display CPU ID and revision information
 	 * too ... that will matter as more revisions appear.
@@ -184,11 +194,11 @@ int print_cpuinfo(void)
 			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
 				/ 2);
 	return 0;
-}
 
-#ifdef DAVINCI_DM6467EVM
-unsigned int davinci_arm_clk_get()
-{
-	return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV) * 1000000;
 }
-#endif
+
+U_BOOT_CMD(
+	clocks,	1, 0, showclocks,
+	"display clocks",
+	""
+);
Signature · 1 line
1.6.2.4
#5 lore raw

PATCH 4/5 dm365: add support to print cpu clock information

In reply to nagabhushana.netagunte at ti.com

From: Nagabhushana Netagunte <[email protected]>

add support for dm365 in speed.c file to use appropriate PLL clocks to calculate cpu frequency and print.

---
 arch/arm/cpu/arm926ejs/davinci/speed.c |   44 +++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 6 deletions(-)
arch/arm/cpu/arm926ejs/davinci/speed.c +38 -6
index ebcd212..8650061 100644
@@ -50,6 +50,13 @@
 #define DDR_PLLDIV	PLLC_PLLDIV1
 #endif
 
+#ifdef CONFIG_SOC_DM365
+#define ARM_PLLDIV	PLLC_PLLDIV2
+#define DDR_PLLDIV	PLLC_PLLDIV7
+#define SYSTEM_MOD	0x01C40000
+#define PERL_CTRL	0x48
+#endif
+
 #ifdef CONFIG_SOC_DM644X
 #define ARM_PLLDIV	PLLC_PLLDIV2
 #define DSP_PLLDIV	PLLC_PLLDIV1
@@ -129,12 +136,14 @@ static unsigned pll_div(volatile void *pllbase, unsigned offset)
 
 static inline unsigned pll_prediv(volatile void *pllbase)
 {
-#ifdef CONFIG_SOC_DM355
+#if defined(CONFIG_SOC_DM355) || defined(CONFIG_SOC_DM365)
 	/* this register read seems to fail on pll0 */
 	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
 		return 8;
 	else
 		return pll_div(pllbase, PLLC_PREDIV);
+#elif defined(CONFIG_SOC_DM365)
+		return pll_div(pllbase, PLLC_PREDIV);
 #endif
 	return 1;
 }
@@ -162,7 +171,11 @@ static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
 	/* the PLL might be bypassed */
 	if (REG(pllbase + PLLC_PLLCTL) & BIT(0)) {
 		base /= pll_prediv(pllbase);
-		base *= 1 + (REG(pllbase + PLLC_PLLM) & 0x0ff);
+#ifdef CONFIG_SOC_DM365
+		base *= (2 * (REG(pllbase + PLLC_PLLM) & 0x3ff));
+#else
+		base *=  (1 + (REG(pllbase + PLLC_PLLM) & 0x0ff));
+#endif
 		base /= pll_postdiv(pllbase);
 	}
 	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
@@ -181,18 +194,37 @@ int showclocks(cmd_tbl_t *cmdtp,
 	/* REVISIT fetch and display CPU ID and revision information
 	 * too ... that will matter as more revisions appear.
 	 */
-	printf("Cores: ARM %d MHz",
-			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
+	unsigned int pllbase;
+	unsigned int sysdiv;
+
+	pllbase = DAVINCI_PLL_CNTRL0_BASE;
+	sysdiv = ARM_PLLDIV;
+#ifdef CONFIG_SOC_DM365
+	pllbase = (REG(SYSTEM_MOD + PERL_CTRL) & BIT(29)) ?
+			DAVINCI_PLL_CNTRL1_BASE : DAVINCI_PLL_CNTRL0_BASE;
+#endif
+
+	printf("Cores: ARM %d MHz", pll_sysclk_mhz(pllbase, sysdiv));
 
 #ifdef DSP_PLLDIV
 	printf(", DSP %d MHz",
 			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, DSP_PLLDIV));
 #endif
 
+	pllbase = DAVINCI_PLL_CNTRL1_BASE;
+	sysdiv = DDR_PLLDIV;
+
+#ifdef CONFIG_SOC_DM365
+	pllbase = (REG(SYSTEM_MOD + PERL_CTRL) & BIT(27)) ?
+			 DAVINCI_PLL_CNTRL1_BASE : DAVINCI_PLL_CNTRL0_BASE;
+
+	if (pllbase == DAVINCI_PLL_CNTRL1_BASE)
+		sysdiv = PLLC_PLLDIV3;
+#endif
+
 	printf("\nDDR:   %d MHz\n",
 			/* DDR PHY uses an x2 input clock */
-			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
-				/ 2);
+			pll_sysclk_mhz(pllbase, sysdiv)/2);
 	return 0;
 
 }
Signature · 1 line
1.6.2.4
#6 lore raw

PATCH 5/5 da8xx: print ARM and DDR frequency from u-boot

In reply to nagabhushana.netagunte at ti.com

From: Nagabhushana Netagunte <[email protected]>

print ARM and DDR frequency for da8xx as part of clocks command and a function is added in hardware.h to find which PLL clock is used.

---
 arch/arm/cpu/arm926ejs/davinci/speed.c       |    7 +++++++
 arch/arm/include/asm/arch-davinci/hardware.h |   11 +++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/davinci/speed.c +7 -0
index 8650061..4bf72d5 100644
@@ -194,6 +194,11 @@ int showclocks(cmd_tbl_t *cmdtp,
 	/* REVISIT fetch and display CPU ID and revision information
 	 * too ... that will matter as more revisions appear.
 	 */
+
+#ifdef CONFIG_SOC_DA8XX
+	printf("ARM Clock : %d Hz\n", clk_get(DAVINCI_ARM_CLKID));
+	printf("DDR Clock : %d Hz\n", clk_get(DAVINCI_DDR_CLKID)/2);
+#else
 	unsigned int pllbase;
 	unsigned int sysdiv;
 
@@ -225,6 +230,8 @@ int showclocks(cmd_tbl_t *cmdtp,
 	printf("\nDDR:   %d MHz\n",
 			/* DDR PHY uses an x2 input clock */
 			pll_sysclk_mhz(pllbase, sysdiv)/2);
+#endif
+
 	return 0;
 
 }
arch/arm/include/asm/arch-davinci/hardware.h +11 -0
index 692d507..0ec594a 100644
@@ -401,8 +401,13 @@ struct davinci_pllc_regs {
 #define DAVINCI_PLLC_DIV_MASK	0x1f
 
 #define ASYNC3          get_async3_src()
+#define EMIFB		get_emifb_src()
+
+#define PLL1_PLLM		((1 << 16) | DAVINCI_PLLM_CLKID)
+#define PLL1_SYSCLK1		((1 << 16) | 0x1)
 #define PLL1_SYSCLK2		((1 << 16) | 0x2)
 #define DAVINCI_SPI1_CLKID  (cpu_is_da830() ? 2 : ASYNC3)
+#define DAVINCI_DDR_CLKID	EMIFB
 /* Clock IDs */
 enum davinci_clk_ids {
 	DAVINCI_SPI0_CLKID = 2,
@@ -506,6 +511,12 @@ static inline int get_async3_src(void)
 			PLL1_SYSCLK2 : 2;
 }
 
+static inline int get_emifb_src(void)
+{
+	return (REG(&davinci_syscfg_regs->cfgchip3) & 0x80) ?
+			PLL1_PLLM : PLL1_SYSCLK1;
+}
+
 #endif /* CONFIG_SOC_DA8XX */
 
 #endif /* __ASM_ARCH_HARDWARE_H */
Signature · 1 line
1.6.2.4