Skip to contentSkip to conversation

davinci: display correct clock info

PATCH New David Brownell 3 participants 10 messages Apr 29, 2009 – May 1, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 davinci: display correct clock info

From: David Brownell <[email protected]>

Make the DaVinci clock display code work on the dm355 too ... there are pre- and post- dividers on its PLLs, which most other DaVinci processors don't use; and it uses different PLL dividers. Stubbed in support for the DM6467 too. Verified on dm355 and dm6446.

---
This should move to cpu/arm926ejs/davinci (cpuinfo.c?) someday, like the other SoC-specific code. For another patch.

 board/davinci/common/misc.c |   88 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 83 insertions(+), 5 deletions(-)
board/davinci/common/misc.c +83 -5
@@ -28,6 +28,40 @@
 #include <net.h>
 #include <asm/arch/hardware.h>
 
+
+/* offsets from PLL controller base */
+#define PLLC_PLLCTL	0x100
+#define PLLC_PLLM	0x110
+#define PLLC_PREDIV	0x114
+#define PLLC_PLLDIV1	0x118
+#define PLLC_PLLDIV2	0x11c
+#define PLLC_PLLDIV3	0x120
+#define PLLC_POSTDIV	0x128
+#define PLLC_BPDIV	0x12c
+#define PLLC_PLLDIV4	0x160
+#define PLLC_PLLDIV5	0x164
+#define PLLC_PLLDIV6	0x168
+#define PLLC_PLLDIV8	0x170
+#define PLLC_PLLDIV9	0x174
+
+#define BIT(x)		(1 << (x))
+
+/* SOC-specific pll info */
+#ifdef CONFIG_SOC_DM355
+#define ARM_PLLDIV	PLLC_PLLDIV1
+#define DDR_PLLDIV	PLLC_PLLDIV1
+#endif
+
+#ifdef CONFIG_SOC_DM644X
+#define ARM_PLLDIV	PLLC_PLLDIV2
+#define DDR_PLLDIV	PLLC_PLLDIV2
+#endif
+
+#ifdef CONFIG_SOC_DM6447
+#define ARM_PLLDIV	PLLC_PLLDIV2
+#define DDR_PLLDIV	PLLC_PLLDIV1
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
@@ -38,16 +72,60 @@ int dram_init(void)
 	return(0);
 }
 
-static int dv_get_pllm_output(uint32_t pllm)
+static unsigned pll_div(volatile void *pllbase, unsigned offset)
 {
-	return (pllm + 1) * (CONFIG_SYS_HZ_CLOCK / 1000000);
+	u32	div;
+
+	div = REG(pllbase + offset);
+	return (div & BIT(15)) ? (1 + (div & 0x1f)) : 1;
+}
+
+static inline unsigned pll_prediv(volatile void *pllbase)
+{
+#ifdef CONFIG_SOC_DM355
+	/* 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);
+#endif
+	return 1;
+}
+
+static inline unsigned pll_postdiv(volatile void *pllbase)
+{
+#ifdef CONFIG_SOC_DM355
+	return pll_div(pllbase, PLLC_POSTDIV);
+#elif defined(CONFIG_SOC_DM6446)
+	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
+		return pll_div(pllbase, PLLC_POSTDIV);
+#endif
+	return 1;
+}
+
+static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
+{
+	volatile void	*pllbase = (volatile void *) pll_addr;
+	unsigned	base = CONFIG_SYS_HZ_CLOCK / 1000;
+
+	/* the PLL might be bypassed */
+	if (REG(pllbase + PLLC_PLLCTL) & BIT(0)) {
+		base /= pll_prediv(pllbase);
+		base *= 1 + (REG(pllbase + PLLC_PLLM) & 0x0ff);
+		base /= pll_postdiv(pllbase);
+	}
+	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
 }
 
 void dv_display_clk_infos(void)
 {
-	printf("ARM Clock: %dMHz\n", dv_get_pllm_output(REG(PLL1_PLLM)) / 2);
-	printf("DDR Clock: %dMHz\n", dv_get_pllm_output(REG(PLL2_PLLM)) /
-	       ((REG(PLL2_DIV2) & 0x1f) + 1) / 2);
+	printf("ARM Clock: %dMHz\n",
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
+	printf("DDR Clock: %dMHz\n",
+			/* DDR PHY uses an x2 input clock */
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
+				/ 2);
+	printf("\n");
 }
 
 #ifdef CONFIG_DRIVER_TI_EMAC
#1 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 11 lines · David Brownell

From: David Brownell <[email protected]>

Make the DaVinci clock display code work on the dm355 too ... there are pre- and post- dividers on its PLLs, which most other DaVinci processors don't use; and it uses different PLL dividers. Stubbed in support for the DM6467 too. Verified on dm355 and dm6446.

---
This should move to cpu/arm926ejs/davinci (cpuinfo.c?) someday, like the other SoC-specific code. For another patch.

good idea

cpu.c will be better

btw a clock design as done for at91 & avr32 will be nice too

Quoted 15 lines
 board/davinci/common/misc.c |   88 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 83 insertions(+), 5 deletions(-)
board/davinci/common/misc.c +5 -0
@@ -28,6 +28,40 @@
 #include <net.h>
 #include <asm/arch/hardware.h>
 
+
+/* offsets from PLL controller base */
+#define PLLC_PLLCTL	0x100
+#define PLLC_PLLM	0x110
+#define PLLC_PREDIV	0x114

board/davinci/common/misc.c line 45

Quoted 10 lines
board/davinci/common/misc.c +10 -0
+#define PLLC_PLLDIV1	0x118
+#define PLLC_PLLDIV2	0x11c
+#define PLLC_PLLDIV3	0x120
+#define PLLC_POSTDIV	0x128
+#define PLLC_BPDIV	0x12c
+#define PLLC_PLLDIV4	0x160
+#define PLLC_PLLDIV5	0x164
+#define PLLC_PLLDIV6	0x168
+#define PLLC_PLLDIV8	0x170
+#define PLLC_PLLDIV9	0x174

who will init the PLL?
can we detect it if they are already init?

board/davinci/common/misc.c line 47

Quoted 2 lines
board/davinci/common/misc.c +2 -0
+
+#define BIT(x)		(1 << (x))

please remove

Quoted 28 lines
board/davinci/common/misc.c +18 -2
+
+/* SOC-specific pll info */
+#ifdef CONFIG_SOC_DM355
+#define ARM_PLLDIV	PLLC_PLLDIV1
+#define DDR_PLLDIV	PLLC_PLLDIV1
+#endif
+
+#ifdef CONFIG_SOC_DM644X
+#define ARM_PLLDIV	PLLC_PLLDIV2
+#define DDR_PLLDIV	PLLC_PLLDIV2
+#endif
+
+#ifdef CONFIG_SOC_DM6447
+#define ARM_PLLDIV	PLLC_PLLDIV2
+#define DDR_PLLDIV	PLLC_PLLDIV1
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
@@ -38,16 +72,60 @@ int dram_init(void)
 	return(0);
 }
 
-static int dv_get_pllm_output(uint32_t pllm)
+static unsigned pll_div(volatile void *pllbase, unsigned offset)
 {
-	return (pllm + 1) * (CONFIG_SYS_HZ_CLOCK / 1000000);

board/davinci/common/misc.c int dram_init(void) · line 86

Quoted 10 lines
board/davinci/common/misc.c +10 -0
+	u32	div;
+
+	div = REG(pllbase + offset);
+	return (div & BIT(15)) ? (1 + (div & 0x1f)) : 1;
+}
+
+static inline unsigned pll_prediv(volatile void *pllbase)
+{
+#ifdef CONFIG_SOC_DM355
+	/* this register read seems to fail on pll0 */

maybe an errata?

Quoted 35 lines
board/davinci/common/misc.c +31 -0
+	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
+		return 8;
+	else
+		return pll_div(pllbase, PLLC_PREDIV);
+#endif
+	return 1;
+}
+
+static inline unsigned pll_postdiv(volatile void *pllbase)
+{
+#ifdef CONFIG_SOC_DM355
+	return pll_div(pllbase, PLLC_POSTDIV);
+#elif defined(CONFIG_SOC_DM6446)
+	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
+		return pll_div(pllbase, PLLC_POSTDIV);
+#endif
+	return 1;
+}
+
+static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
+{
+	volatile void	*pllbase = (volatile void *) pll_addr;
+	unsined	base = CONFIG_SYS_HZ_CLOCK / 1000;
+
+	/* the PLL might be bypassed */
+	if (REG(pllbase + PLLC_PLLCTL) & BIT(0)) {
+		base /= pll_prediv(pllbase);
+		base *= 1 + (REG(pllbase + PLLC_PLLM) & 0x0ff);
+		base /= pll_postdiv(pllbase);
+	}
+	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
 }
 
 void dv_display_clk_infos(void)
 {

board/davinci/common/misc.c int dram_init(void) · line 128

Quoted 10 lines
board/davinci/common/misc.c +7 -3
-	printf("ARM Clock: %dMHz\n", dv_get_pllm_output(REG(PLL1_PLLM)) / 2);
-	printf("DDR Clock: %dMHz\n", dv_get_pllm_output(REG(PLL2_PLLM)) /
-	       ((REG(PLL2_DIV2) & 0x1f) + 1) / 2);
+	printf("ARM Clock: %dMHz\n",
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
+	printf("DDR Clock: %dMHz\n",
+			/* DDR PHY uses an x2 input clock */
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
+				/ 2);
+	printf("\n");

puts("");

Best Regards,
J.

#2 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · David Brownell

From: David Brownell <[email protected]>

Make the DaVinci clock display code work on the dm355 too ... there are pre- and post- dividers on its PLLs, which most other DaVinci processors don't use; and it uses different PLL dividers. Stubbed in support for the DM6467 too. Verified on dm355 and dm6446.

Quoted 10 lines
Quoted 5 lines

---
This should move to cpu/arm926ejs/davinci (cpuinfo.c?) someday, like the other SoC-specific code. For another patch.

good idea

cpu.c will be better

Good idea. This would give me a happy place for the cpu_eth_init() as mentioned in another thread.

regards,
Ben

#3 lore raw

PATCH 1/1 davinci: display correct clock info

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · David Brownell

From: David Brownell <[email protected]>

Make the DaVinci clock display code work on the dm355 too ... there are pre- and post- dividers on its PLLs, which most other DaVinci processors don't use; and it uses different PLL dividers. Stubbed in support for the DM6467 too. Verified on dm355 and dm6446.

Quoted 8 lines
Quoted 4 lines

---
This should move to cpu/arm926ejs/davinci (cpuinfo.c?) someday, like the other SoC-specific code. For another patch.

good idea

cpu.c will be better

I was thinking of using CONFIG_DISPLAY_CPUINFO hooks for that, and those seem to be in cpuinfo.c files. (Someday, when time allows.)

Quoted 1 line

btw a clock design as done for at91 & avr32 will be nice too

It's missing from at91rm9200 ... ;)

Those seem to be useful if U-Boot is the first stage boot loader, running out of NOR flash and needing to do lots of low level setup: configure PLLs, clock divisors, memory timings, start DRAM, and so on.

But most DaVinci boards boot from NAND flash nowadays, making U-boot be a third stage loader with no lowlevel init. So it doesn't need such code ... but if it did, it would touch the PLL controllers in very different ways (modifying the registers and handshaking, not just reading like this).

Quoted 9 lines
Quoted 9 lines
board/davinci/common/misc.c +9 -0
+/* offsets from PLL controller base */
+#define PLLC_PLLCTL	0x100
+#define PLLC_PLLM	0x110
+#define PLLC_PREDIV	0x114
+#define PLLC_PLLDIV1	0x118
+#define PLLC_PLLDIV2	0x11c
+#define PLLC_PLLDIV3	0x120
+#define PLLC_POSTDIV	0x128
+#define PLLC_BPDIV	0x12c
Quoted 8 lines

board/davinci/common/misc.c line 45

Quoted 5 lines
board/davinci/common/misc.c +5 -0
+#define PLLC_PLLDIV4	0x160
+#define PLLC_PLLDIV5	0x164
+#define PLLC_PLLDIV6	0x168
+#define PLLC_PLLDIV8	0x170
+#define PLLC_PLLDIV9	0x174

who will init the PLL?
can we detect it if they are already init?

PLL setup is part of lowlevel init ... usually it's done by the second stage boot loader (UBL) if this is booting from anything except NOR flash. For NOR boot that's now done in cpu/.../lowlevel_init.S code.

By the time this code is called, that's been done a long time ago ... we're running out of DRAM, which can't work without active PLLs. (The oscillator is from 20-30 MHz, the DRAM clock must be 125 MHz and up, QED.)

Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+#define BIT(x)		(1 << (x))

please remove

When there's a standard definition somewhere ... the one in include/asm/arch-ixp/ixp425.h is unusable here.

Quoted 7 lines

board/davinci/common/misc.c int dram_init(void) · line 86

Quoted 5 lines
board/davinci/common/misc.c +5 -0
+
+static inline unsigned pll_prediv(volatile void *pllbase)
+{
+#ifdef CONFIG_SOC_DM355
+	/* this register read seems to fail on pll0 */

maybe an errata?

I didn't see it published, if so. I noticed that issue when doing similar code on Linux.

Quoted 5 lines
Quoted 5 lines

void dv_display_clk_infos(void)
{

board/davinci/common/misc.c +0 -3
-	printf("ARM Clock: %dMHz\n", dv_get_pllm_output(REG(PLL1_PLLM)) / 2);
-	printf("DDR Clock: %dMHz\n", dv_get_pllm_output(REG(PLL2_PLLM)) /
-	       ((REG(PLL2_DIV2) & 0x1f) + 1) / 2);
Quoted 8 lines

board/davinci/common/misc.c int dram_init(void) · line 128

Quoted 7 lines
board/davinci/common/misc.c +7 -0
+	printf("ARM Clock: %dMHz\n",
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
+	printf("DDR Clock: %dMHz\n",
+			/* DDR PHY uses an x2 input clock */
+			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
+				/ 2);
+	printf("\n");

puts("");

OK

Quoted 5 lines

Best Regards,
J.

#4 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 18 lines · David Brownell
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · David Brownell

From: David Brownell <[email protected]>

Make the DaVinci clock display code work on the dm355 too ... there are pre- and post- dividers on its PLLs, which most other DaVinci processors don't use; and it uses different PLL dividers. Stubbed in support for the DM6467 too. Verified on dm355 and dm6446.

Quoted 8 lines
Quoted 4 lines

---
This should move to cpu/arm926ejs/davinci (cpuinfo.c?) someday, like the other SoC-specific code. For another patch.

good idea

cpu.c will be better

Quoted 8 lines

I was thinking of using CONFIG_DISPLAY_CPUINFO hooks for that, and those seem to be in cpuinfo.c files. (Someday, when time allows.)

Quoted 1 line

btw a clock design as done for at91 & avr32 will be nice too

It's missing from at91rm9200 ... ;)

sure but in preparaton as the at91rm9200 will be merge with the AT91 soon

Quoted 11 lines

Those seem to be useful if U-Boot is the first stage boot loader, running out of NOR flash and needing to do lots of low level setup: configure PLLs, clock divisors, memory timings, start DRAM, and so on.

But most DaVinci boards boot from NAND flash nowadays, making U-boot be a third stage loader with no lowlevel init. So it doesn't need such code ... but if it did, it would touch the PLL controllers in very different ways (modifying the registers and handshaking, not just reading like this).

ok the calc clock, I've more in mind the get_xxx_clk_rate() api

Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
board/davinci/common/misc.c +9 -0
+/* offsets from PLL controller base */
+#define PLLC_PLLCTL	0x100
+#define PLLC_PLLM	0x110
+#define PLLC_PREDIV	0x114
+#define PLLC_PLLDIV1	0x118
+#define PLLC_PLLDIV2	0x11c
+#define PLLC_PLLDIV3	0x120
+#define PLLC_POSTDIV	0x128
+#define PLLC_BPDIV	0x12c
Quoted 8 lines

board/davinci/common/misc.c line 45

Quoted 5 lines
board/davinci/common/misc.c +5 -0
+#define PLLC_PLLDIV4	0x160
+#define PLLC_PLLDIV5	0x164
+#define PLLC_PLLDIV6	0x168
+#define PLLC_PLLDIV8	0x170
+#define PLLC_PLLDIV9	0x174

who will init the PLL?
can we detect it if they are already init?

PLL setup is part of lowlevel init ... usually it's done by the second stage boot loader (UBL) if this is booting from anything except NOR flash. For NOR boot that's now done in cpu/.../lowlevel_init.S code.

Quoted 5 lines

By the time this code is called, that's been done a long time ago ... we're running out of DRAM, which can't work without active PLLs. (The oscillator is from 20-30 MHz, the DRAM clock must be 125 MHz and up, QED.)

my idea is more this
the lowlovel will init the pll (lowlevel_init.S or other stage bootloader) so instead of hardcoding the PPLDIV read it in the register
and then calculate the clock rate and it need it set the other non used clock depending on the IP used by u-boot (at runtime)

Best Regards,
J.

#5 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD

my idea is more this
the lowlovel will init the pll (lowlevel_init.S or other stage bootloader)

Right ...

Quoted 2 lines

so instead of hardcoding the PPLDIV read it in the register and then calculate the clock rate

That's all this code does: read the PLL registers (and divider taps), and display settings in use by the current board. It happens that some SoCs have slightly different PLL configuration (like pre/post dividers) and feed important components (ARM, DSP, DDR) from different PLL dividers.

Quoted 2 lines

and it need it set the other non used clock
depending on the IP used by u-boot (at runtime)

I don't know what you mean here. PLL/tap configuration is distinct from clock distribution on the chip.

The cpu/arm926ejs/davinci/psc.c code handles clock distribution (and resets). So for example the dm355 chips leave most modules clocked but in reset, while the dm6446 leaves them unclocked and in reset ... so modules needed by u-boot get uniformly taken out of reset and clocked. But that's *unrelated* to this PLL display code.

- Dave

#6 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 7 lines · David Brownell
Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD

my idea is more this
the lowlovel will init the pll (lowlevel_init.S or other stage bootloader)

Right ...

Quoted 6 lines
Quoted 2 lines

so instead of hardcoding the PPLDIV read it in the register and then calculate the clock rate

That's all this code does: read the PLL registers (and divider taps), and display settings in use by the current board.

yes but it's does not provice help full api to use it other where in the code

Quoted 4 lines

It happens that some SoCs have
slightly different PLL configuration (like pre/post dividers) and feed important components (ARM, DSP, DDR) from different PLL dividers.

the PLL dividers are hardcoded why?

Quoted 8 lines
Quoted 4 lines

and it need it set the other non used clock
depending on the IP used by u-boot (at runtime)

I don't know what you mean here. PLL/tap configuration is distinct from clock distribution on the chip.

Quoted 6 lines

The cpu/arm926ejs/davinci/psc.c code handles clock distribution (and resets). So for example the dm355 chips leave most modules clocked but in reset, while the dm6446 leaves them unclocked and in reset ... so modules needed by u-boot get uniformly taken out of reset and clocked.

I known that's why I've in mind to set only the clock if we use the drivers/IP at run time othewise let it off

Quoted 2 lines

But that's *unrelated* to this
PLL display code.

I agree this not for this patch but for an improvement

Best Regards,
J.

#7 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 10 lines · David Brownell
Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD

my idea is more this
the lowlovel will init the pll (lowlevel_init.S or other stage bootloader)

Right ...

Quoted 2 lines

so instead of hardcoding the PPLDIV read it in the register and then calculate the clock rate

Quoted 6 lines
Quoted 3 lines

That's all this code does: read the PLL registers (and divider taps), and display settings in use by the current board.

yes but it's does not provice help full api to use it other where in the code

Use it where/why? There's not been a need for anything analagous to <linux/clk.h> ...

Quoted 6 lines
Quoted 4 lines

It happens that some SoCs have
slightly different PLL configuration (like pre/post dividers) and feed important components (ARM, DSP, DDR) from different PLL dividers.

the PLL dividers are hardcoded why?

A few are hard-wired in silicon, others are programmable. Either way, they rarely change after lowlevel init.

Mostly it's a case of *which* divider -- DIV1, DIV2, DIV4, etc. Each divider feeds a fixed set of modules, and different SoCs map them differently: fixed/not, which modules, allowable frequency ranges, etc.

It happens that the cases U-Boot cares about today bypass the PLL and dividers entirely: clocks going to timer and the UART directly match the main xtal. Or, like USB, the exact clock rate is either hard wired (60 MHz for the PHY) or doesn't matter.

- Dave

#8 lore raw

PATCH 1/1 davinci: display correct clock info

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD

cpu.c will be better

Here's a followup patch that applies on top of this one, and creates the cpu.c you wanted.

=== CUT HERE
From: David Brownell <[email protected]>

Move the clock-rate dumping code into the cpu/.../davinci area where it should have been, enabled by CONFIG_DISPLAY_CPUINFO, updating the format and showing the DSP clock (where relevant).

Switch boards to use the cpuinfo() hook for this stuff.

Remove a few now-obsolete PLL #defines.

---
 board/davinci/common/misc.c             |   89 --------------------
 board/davinci/common/misc.h             |    1 
 board/davinci/dvevm/dvevm.c             |    2 
 board/davinci/schmoogie/schmoogie.c     |    2 
 board/davinci/sffsdr/sffsdr.c           |    2 
 board/davinci/sonata/sonata.c           |    2 
 cpu/arm926ejs/davinci/Makefile          |    2 
 cpu/arm926ejs/davinci/cpu.c             |  131 ++++++++++++++++++++++++++++++
 include/asm-arm/arch-davinci/hardware.h |    5 -
 include/configs/davinci_dvevm.h         |    1 
 include/configs/davinci_schmoogie.h     |    1 
 include/configs/davinci_sffsdr.h        |    4 
 include/configs/davinci_sonata.h        |    1 
 13 files changed, 137 insertions(+), 106 deletions(-)
board/davinci/common/misc.c +0 -89
@@ -29,39 +29,6 @@
 #include <asm/arch/hardware.h>
 
 
-/* offsets from PLL controller base */
-#define PLLC_PLLCTL	0x100
-#define PLLC_PLLM	0x110
-#define PLLC_PREDIV	0x114
-#define PLLC_PLLDIV1	0x118
-#define PLLC_PLLDIV2	0x11c
-#define PLLC_PLLDIV3	0x120
-#define PLLC_POSTDIV	0x128
-#define PLLC_BPDIV	0x12c
-#define PLLC_PLLDIV4	0x160
-#define PLLC_PLLDIV5	0x164
-#define PLLC_PLLDIV6	0x168
-#define PLLC_PLLDIV8	0x170
-#define PLLC_PLLDIV9	0x174
-
-#define BIT(x)		(1 << (x))
-
-/* SOC-specific pll info */
-#ifdef CONFIG_SOC_DM355
-#define ARM_PLLDIV	PLLC_PLLDIV1
-#define DDR_PLLDIV	PLLC_PLLDIV1
-#endif
-
-#ifdef CONFIG_SOC_DM644X
-#define ARM_PLLDIV	PLLC_PLLDIV2
-#define DDR_PLLDIV	PLLC_PLLDIV2
-#endif
-
-#ifdef CONFIG_SOC_DM6447
-#define ARM_PLLDIV	PLLC_PLLDIV2
-#define DDR_PLLDIV	PLLC_PLLDIV1
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
@@ -72,62 +39,6 @@ int dram_init(void)
 	return(0);
 }
 
-static unsigned pll_div(volatile void *pllbase, unsigned offset)
-{
-	u32	div;
-
-	div = REG(pllbase + offset);
-	return (div & BIT(15)) ? (1 + (div & 0x1f)) : 1;
-}
-
-static inline unsigned pll_prediv(volatile void *pllbase)
-{
-#ifdef CONFIG_SOC_DM355
-	/* 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);
-#endif
-	return 1;
-}
-
-static inline unsigned pll_postdiv(volatile void *pllbase)
-{
-#ifdef CONFIG_SOC_DM355
-	return pll_div(pllbase, PLLC_POSTDIV);
-#elif defined(CONFIG_SOC_DM6446)
-	if (pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE)
-		return pll_div(pllbase, PLLC_POSTDIV);
-#endif
-	return 1;
-}
-
-static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div)
-{
-	volatile void	*pllbase = (volatile void *) pll_addr;
-	unsigned	base = CONFIG_SYS_HZ_CLOCK / 1000;
-
-	/* the PLL might be bypassed */
-	if (REG(pllbase + PLLC_PLLCTL) & BIT(0)) {
-		base /= pll_prediv(pllbase);
-		base *= 1 + (REG(pllbase + PLLC_PLLM) & 0x0ff);
-		base /= pll_postdiv(pllbase);
-	}
-	return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div));
-}
-
-void dv_display_clk_infos(void)
-{
-	printf("ARM Clock: %dMHz\n",
-			pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV));
-	printf("DDR Clock: %dMHz\n",
-			/* DDR PHY uses an x2 input clock */
-			pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV)
-				/ 2);
-	printf("\n");
-}
-
 #ifdef CONFIG_DRIVER_TI_EMAC
 
 /* Read ethernet MAC address from EEPROM for DVEVM compatible boards.
board/davinci/common/misc.h +0 -1
@@ -24,7 +24,6 @@
 
 extern int eth_hw_init(void);
 
-void dv_display_clk_infos(void);
 int dvevm_read_mac_address(uint8_t *buf);
 void dv_configure_mac_address(uint8_t *rom_enetaddr);
 
board/davinci/dvevm/dvevm.c +0 -2
@@ -69,8 +69,6 @@ int misc_init_r(void)
 	uint8_t video_mode;
 	uint8_t eeprom_enetaddr[6];
 
-	dv_display_clk_infos();
-
 	/* Read Ethernet MAC address from EEPROM if available. */
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
board/davinci/schmoogie/schmoogie.c +0 -2
@@ -104,8 +104,6 @@ int misc_init_r(void)
 			0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35
 		};
 
-	dv_display_clk_infos();
-
 	/* Set serial number from UID chip */
 	if (i2c_read(CONFIG_SYS_UID_ADDR, 0, 1, buf, 8)) {
 		printf("\nUID @ 0x%02x read FAILED!!!\n", CONFIG_SYS_UID_ADDR);
board/davinci/sffsdr/sffsdr.c +0 -2
@@ -131,8 +131,6 @@ int misc_init_r(void)
 	/* EMIF-A CS3 configuration for FPGA. */
 	REG(DAVINCI_A3CR) = DAVINCI_A3CR_VAL;
 
-	dv_display_clk_infos();
-
 	/* Configure I2C switch (PCA9543) to enable channel 0. */
 	i2cbuf = CONFIG_SYS_I2C_PCA9543_ENABLE_CH0;
 	if (i2c_write(CONFIG_SYS_I2C_PCA9543_ADDR, 0,
board/davinci/sonata/sonata.c +0 -2
@@ -66,8 +66,6 @@ int misc_init_r(void)
 {
 	uint8_t eeprom_enetaddr[6];
 
-	dv_display_clk_infos();
-
 	/* Read Ethernet MAC address from EEPROM if available. */
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
cpu/arm926ejs/davinci/Makefile +1 -1
@@ -27,7 +27,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(SOC).a
 
-COBJS-y				+= timer.o psc.o
+COBJS-y				+= cpu.o timer.o psc.o
 COBJS-$(CONFIG_SOC_DM355)	+= dm355.o
 COBJS-$(CONFIG_SOC_DM644X)	+= dm644x.o
 COBJS-$(CONFIG_DRIVER_TI_EMAC)	+= ether.o lxt972.o dp83848.o
cpu/arm926ejs/davinci/cpu.c new file +131 -0

131 lines not on this page · raw message

include/asm-arm/arch-davinci/hardware.h +0 -5
@@ -175,11 +175,6 @@ void davinci_errata_workarounds(void);
 
 #define PSC_SILVER_BULLET		(0x01c41a20)
 
-/* Some PLL defines */
-#define PLL1_PLLM			(0x01c40910)
-#define PLL2_PLLM			(0x01c40d10)
-#define PLL2_DIV2			(0x01c40d1c)
-
 /* Miscellania... */
 #define VBPR				(0x20000020)
 
include/configs/davinci_dvevm.h +1 -0
@@ -52,6 +52,7 @@
 #define DV_EVM
 #define CONFIG_SYS_NAND_SMALLPAGE
 #define CONFIG_SYS_USE_NOR
+#define CONFIG_DISPLAY_CPUINFO
 /*===================*/
 /* SoC Configuration */
 /*===================*/
include/configs/davinci_schmoogie.h +1 -0
@@ -27,6 +27,7 @@
 #define SCHMOOGIE
 #define CONFIG_SYS_NAND_LARGEPAGE
 #define CONFIG_SYS_USE_NAND
+#define CONFIG_DISPLAY_CPUINFO
 /*===================*/
 /* SoC Configuration */
 /*===================*/
include/configs/davinci_sffsdr.h +2 -2
@@ -28,8 +28,8 @@
 #define SFFSDR
 #define CONFIG_SYS_NAND_LARGEPAGE
 #define CONFIG_SYS_USE_NAND
-#define CONFIG_SYS_USE_DSPLINK		/* This is to prevent U-Boot from
-				 * powering ON the DSP. */
+#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 +1 -0
@@ -52,6 +52,7 @@
 #define SONATA_BOARD
 #define CONFIG_SYS_NAND_SMALLPAGE
 #define CONFIG_SYS_USE_NOR
+#define CONFIG_DISPLAY_CPUINFO
 /*===================*/
 /* SoC Configuration */
 /*===================*/
#9 lore raw

PATCH 1/1 davinci: display correct clock info

Quoted 5 lines · David Brownell
Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD

cpu.c will be better

Here's a followup patch that applies on top of this one, and creates the cpu.c you wanted.

please move this

Quoted 9 lines

=== CUT HERE
From: David Brownell <[email protected]>

Move the clock-rate dumping code into the cpu/.../davinci area where it should have been, enabled by CONFIG_DISPLAY_CPUINFO, updating the format and showing the DSP clock (where relevant).

Quoted 6 lines

Switch boards to use the cpuinfo() hook for this stuff.

Remove a few now-obsolete PLL #defines.

---

HERE

it will help to not manually fix the patch

applied to arm/next

Best Regards,
J.