Skip to contentSkip to conversation

Remove duplicate functions for power and sleep configuration

PATCH New Christian Riesch 3 participants 14 messages Oct 12, 2011 – Oct 16, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Remove duplicate functions for power and sleep configuration

Hi,
these patches apply on top of Heiko Schocher's patches for the enbw_cmc board. They remove the duplicate functions for the power and sleep controller of the davinci devices.

The first patch renames the low level configuration functions since they can not only be used for the AM1808 but for the entire da850 family.

The second patch corrects the mask for the state bitfield of the MDSTAT registers. Similar patches have been already submitted for the Linux kernel and other parts of u-boot, see e.g. http://patchwork.ozlabs.org/patch/114942/

Patch number three adds a function to set an LPSC module to Sync Reset state as this is required for DDR memory controller initialization.

The forth patch finally replaces the PSC related functions in arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c by those of psc.c.

I tested the DDR initialization functions on my board and they worked fine, but of course I can only compile-test them for Heiko's board.

I am looking forward to your comments!

Prerequisites:

[U-Boot] arm, post, memory: fix bug if sdram base != 0x00000000
http://patchwork.ozlabs.org/patch/118208/

[U-Boot] : davinci: Replace CONFIG_PRELOADER with CONFIG_SPL_BUILD in board/davinci/common/misc.c
http://patchwork.ozlabs.org/patch/114482/

[U-Boot] arm, fdt: update ethernet mac address before booting Linux
http://patchwork.ozlabs.org/patch/114736/

[U-Boot] arm, logbuffer: make it compileclean
http://patchwork.ozlabs.org/patch/114740/

[U-Boot] cosmetic, post: Codingstyle cleanup
http://patchwork.ozlabs.org/patch/114742/

[U-Boot] arm, post: add missing post_time_ms for arm
http://patchwork.ozlabs.org/patch/114743/

[U-Boot,v2,1/3] arm, davinci: fix typo in arch/arm/cpu/arm926ejs/davinci/Makefile
http://patchwork.ozlabs.org/patch/118310/

[U-Boot,v2,2/3] arm, davinci: add DAVINCI_MMC_CLKID
http://patchwork.ozlabs.org/patch/118309/

[U-Boot,v2,3/3] arm, davinci: add support for am1808 based enbw_cmc board
http://patchwork.ozlabs.org/patch/118311/

Regards, Christian

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>

Christian Riesch (4):
arm, davinci: Rename AM1808 lowlevel functions to DA850 arm, davinci: Correct the MDSTAT.STATE mask
arm, davinci: Add function lpsc_syncreset()
arm, davinci: Remove the duplication of LPSC functions in

    da850_lowlevel.c
 arch/arm/cpu/arm926ejs/davinci/Makefile            |    2 +-
 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c   |  428 --------------------
 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c    |  340 ++++++++++++++++
 arch/arm/cpu/arm926ejs/davinci/psc.c               |   20 +-
 .../arm/include/asm/arch-davinci/am1808_lowlevel.h |   44 --
 arch/arm/include/asm/arch-davinci/da850_lowlevel.h |   44 ++
 arch/arm/include/asm/arch-davinci/hardware.h       |    1 +
 board/enbw/enbw_cmc/enbw_cmc.c                     |    2 +-
 include/configs/enbw_cmc.h                         |   92 +++---
 9 files changed, 448 insertions(+), 525 deletions(-)
 delete mode 100644 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
 delete mode 100644 arch/arm/include/asm/arch-davinci/am1808_lowlevel.h
 create mode 100644 arch/arm/include/asm/arch-davinci/da850_lowlevel.h
#1 lore raw

PATCH 1/4 arm, davinci: Rename AM1808 lowlevel functions to DA850

Rename arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c and arch/arm/include/asm/arch-davinci/am1808_lowlevel.h to da850_lowlevel.c and da850_lowlevel.h since they apply not only to the AM1808 SoC but to all DA850 chips. The function names and #defines are changed likewise.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/Makefile            |    2 +-
 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c   |  428 --------------------
 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c    |  428 ++++++++++++++++++++
 .../arm/include/asm/arch-davinci/am1808_lowlevel.h |   44 --
 arch/arm/include/asm/arch-davinci/da850_lowlevel.h |   44 ++
 board/enbw/enbw_cmc/enbw_cmc.c                     |    2 +-
 include/configs/enbw_cmc.h                         |   92 +++---
 7 files changed, 520 insertions(+), 520 deletions(-)
 delete mode 100644 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
 delete mode 100644 arch/arm/include/asm/arch-davinci/am1808_lowlevel.h
 create mode 100644 arch/arm/include/asm/arch-davinci/da850_lowlevel.h
arch/arm/cpu/arm926ejs/davinci/Makefile +1 -1
index d91a2b8..b2152df 100644
@@ -28,7 +28,7 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(SOC).o
 
 COBJS-y				+= cpu.o timer.o psc.o
-COBJS-$(CONFIG_AM1808_LOWLEVEL)       += am1808_lowlevel.o
+COBJS-$(CONFIG_DA850_LOWLEVEL)	+= da850_lowlevel.o
 COBJS-$(CONFIG_SOC_DM355)	+= dm355.o
 COBJS-$(CONFIG_SOC_DM365)	+= dm365.o
 COBJS-$(CONFIG_SOC_DM644X)	+= dm644x.o
arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c deleted +0 -428

428 lines not on this page · raw message

arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c new file +428 -0

428 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/am1808_lowlevel.h deleted +0 -44

44 lines not on this page · raw message

arch/arm/include/asm/arch-davinci/da850_lowlevel.h new file +44 -0

44 lines not on this page · raw message

board/enbw/enbw_cmc/enbw_cmc.c +1 -1
index c25d240..d649d43 100644
@@ -43,7 +43,7 @@
 #include <asm/arch/sdmmc_defs.h>
 #include <asm/arch/timer_defs.h>
 #include <asm/io.h>
-#include <asm/arch/am1808_lowlevel.h>
+#include <asm/arch/da850_lowlevel.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
include/configs/enbw_cmc.h +46 -46

137 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 1/4 arm, davinci: Rename AM1808 lowlevel functions to DA850

Hello Christian,

Quoted 10 lines · Christian Riesch

Rename arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c and arch/arm/include/asm/arch-davinci/am1808_lowlevel.h to da850_lowlevel.c and da850_lowlevel.h since they apply not only to the AM1808 SoC but to all DA850 chips. The function names and #defines are changed likewise.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
Quoted 13 lines
---
 arch/arm/cpu/arm926ejs/davinci/Makefile            |    2 +-
 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c   |  428 --------------------
 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c    |  428 ++++++++++++++++++++
 .../arm/include/asm/arch-davinci/am1808_lowlevel.h |   44 --
 arch/arm/include/asm/arch-davinci/da850_lowlevel.h |   44 ++
 board/enbw/enbw_cmc/enbw_cmc.c                     |    2 +-
 include/configs/enbw_cmc.h                         |   92 +++---
 7 files changed, 520 insertions(+), 520 deletions(-)
 delete mode 100644 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
 delete mode 100644 arch/arm/include/asm/arch-davinci/am1808_lowlevel.h
 create mode 100644 arch/arm/include/asm/arch-davinci/da850_lowlevel.h

Could you please use the -M option of git format-patch, so it detects renames.

Thanks!

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#3 lore raw

PATCH 1/4 arm, davinci: Rename AM1808 lowlevel functions to DA850

Hello Heiko,

Quoted 16 lines · Heiko Schocher

Hello Christian,

Quoted 13 lines · Christian Riesch

Rename arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c and arch/arm/include/asm/arch-davinci/am1808_lowlevel.h to da850_lowlevel.c and da850_lowlevel.h since they apply not only to the AM1808 SoC but to all DA850 chips. The function names and #defines are changed likewise.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/Makefile            |    2 +-
 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c   |  428

--------------------

Quoted 1 line
Quoted 1 line
 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c    |  428

++++++++++++++++++++

Quoted 10 lines
Quoted 9 lines
 .../arm/include/asm/arch-davinci/am1808_lowlevel.h |   44 --
 arch/arm/include/asm/arch-davinci/da850_lowlevel.h |   44 ++
 board/enbw/enbw_cmc/enbw_cmc.c                     |    2 +-
 include/configs/enbw_cmc.h                         |   92 +++---
 7 files changed, 520 insertions(+), 520 deletions(-)
 delete mode 100644 arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c
 create mode 100644 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
 delete mode 100644 arch/arm/include/asm/arch-davinci/am1808_lowlevel.h
 create mode 100644 arch/arm/include/asm/arch-davinci/da850_lowlevel.h
Quoted 2 lines

Could you please use the -M option of git format-patch, so it detects renames.

Thanks for reviewing. I'll use -M when I resubmit the patchset, I didn't know this option :-(
Regards, Christian

#4 lore raw

PATCH 2/4 arm, davinci: Correct the MDSTAT.STATE mask

In reply to Christian Riesch

MDSTAT.STATE occupies bits 0..5 according to all available documentation, therefore change the bitmask to 0x3f.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
Cc Sergei Shtylyov <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/psc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/davinci/psc.c +2 -2
index 8273a7f..486adb0 100644
@@ -83,7 +83,7 @@ void lpsc_on(unsigned int id)
 	while (readl(ptstat) & 0x01)
 		continue;
 
-	if ((readl(mdstat) & 0x1f) == 0x03)
+	if ((readl(mdstat) & 0x3f) == 0x03)
 		return; /* Already on and enabled */
 
 	writel(readl(mdctl) | 0x03, mdctl);
@@ -114,7 +114,7 @@ void lpsc_on(unsigned int id)
 
 	while (readl(ptstat) & 0x01)
 		continue;
-	while ((readl(mdstat) & 0x1f) != 0x03)
+	while ((readl(mdstat) & 0x3f) != 0x03)
 		continue;
 }
 
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH 2/4 arm, davinci: Correct the MDSTAT.STATE mask

Hello.

Quoted 26 lines · Christian Riesch

MDSTAT.STATE occupies bits 0..5 according to all available documentation, therefore change the bitmask to 0x3f.

Cc Heiko Schocher<[email protected]>
Cc Paulraj Sandeep<[email protected]>
Cc Albert ARIBAUD<[email protected]>
Cc Sergei Shtylyov<[email protected]>
---
  arch/arm/cpu/arm926ejs/davinci/psc.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/davinci/psc.c +1 -1
index 8273a7f..486adb0 100644
@@ -83,7 +83,7 @@ void lpsc_on(unsigned int id)
  	while (readl(ptstat)&  0x01)
  		continue;
 
-	if ((readl(mdstat)&  0x1f) == 0x03)
+	if ((readl(mdstat)&  0x3f) == 0x03)
  		return; /* Already on and enabled */
 
  	writel(readl(mdctl) | 0x03, mdctl);

arch/arm/cpu/arm926ejs/davinci/psc.c void lpsc_on(unsigned int id) · line 119

Quoted 7 lines
arch/arm/cpu/arm926ejs/davinci/psc.c +1 -1
@@ -114,7 +114,7 @@ void lpsc_on(unsigned int id)
 
  	while (readl(ptstat)&  0x01)
  		continue;
-	while ((readl(mdstat)&  0x1f) != 0x03)
+	while ((readl(mdstat)&  0x3f) != 0x03)
  		continue;
  }

This patch is incomplete but I guess you've figured that out already as
you've commented on my analogous patch. So marking for the custodian -- don't apply this patch.

WBR, Sergei

#6 lore raw

PATCH 2/4 arm, davinci: Correct the MDSTAT.STATE mask

Hello Sergei,
Thanks for your comments.

Quoted 13 lines · Sergei Shtylyov

Hello.

Quoted 9 lines · Christian Riesch

MDSTAT.STATE occupies bits 0..5 according to all available documentation, therefore change the bitmask to 0x3f.

Cc Heiko Schocher<[email protected]>
Cc Paulraj Sandeep<[email protected]>
Cc Albert ARIBAUD<[email protected]>
Cc Sergei Shtylyov<[email protected]>

---

[...]

Quoted 3 lines

This patch is incomplete but I guess you've figured that out already as
you've commented on my analogous patch. So marking for the custodian --

don't

Quoted 3 lines

apply this patch.

WBR, Sergei

Yes, I have already submitted a v2 of this patchset [1] which does not include this patch anymore but lists your patch as one of the prerequisites.

Best regards, Christian

[1] http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/112215

#7 lore raw

PATCH 3/4 arm, davinci: Add function lpsc_syncreset()

In reply to Christian Riesch

This patch adds a function lpsc_syncreset that allows setting a lpsc module into Sync Reset state.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/psc.c         |   20 +++++++++++++++-----
 arch/arm/include/asm/arch-davinci/hardware.h |    1 +
 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/cpu/arm926ejs/davinci/psc.c +15 -5
index 486adb0..e02d1f6 100644
@@ -46,7 +46,7 @@
  */
 
 /* Works on Always On power domain only (no PD argument) */
-void lpsc_on(unsigned int id)
+static void lpsc_transition(unsigned int id, unsigned int state)
 {
 	dv_reg_p mdstat, mdctl, ptstat, ptcmd;
 #ifdef CONFIG_SOC_DA8XX
@@ -83,10 +83,10 @@ void lpsc_on(unsigned int id)
 	while (readl(ptstat) & 0x01)
 		continue;
 
-	if ((readl(mdstat) & 0x3f) == 0x03)
-		return; /* Already on and enabled */
+	if ((readl(mdstat) & 0x3f) == state)
+		return; /* Already in that state */
 
-	writel(readl(mdctl) | 0x03, mdctl);
+	writel((readl(mdctl) & ~0x1f) | state, mdctl);
 
 	switch (id) {
 #ifdef CONFIG_SOC_DM644X
@@ -114,10 +114,20 @@ void lpsc_on(unsigned int id)
 
 	while (readl(ptstat) & 0x01)
 		continue;
-	while ((readl(mdstat) & 0x3f) != 0x03)
+	while ((readl(mdstat) & 0x3f) != state)
 		continue;
 }
 
+void lpsc_on(unsigned int id)
+{
+	lpsc_transition(id, 0x03);
+}
+
+void lpsc_syncreset(unsigned int id)
+{
+	lpsc_transition(id, 0x01);
+}
+
 /* Not all DaVinci chips have a DSP power domain. */
 #ifdef CONFIG_SOC_DM644X
 
arch/arm/include/asm/arch-davinci/hardware.h +1 -0
index 24ae49d..c87e944 100644
@@ -291,6 +291,7 @@ typedef volatile unsigned int *	dv_reg_p;
 #endif /* CONFIG_SOC_DA8XX */
 
 void lpsc_on(unsigned int id);
+void lpsc_syncreset(unsigned int id);
 void dsp_on(void);
 
 void davinci_enable_uart0(void);
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH 3/4 arm, davinci: Add function lpsc_syncreset()

Hello Christian,

Quoted 26 lines · Christian Riesch

This patch adds a function lpsc_syncreset that allows setting a lpsc module into Sync Reset state.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/psc.c         |   20 +++++++++++++++-----
 arch/arm/include/asm/arch-davinci/hardware.h |    1 +
 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/cpu/arm926ejs/davinci/psc.c +1 -1
index 486adb0..e02d1f6 100644
@@ -46,7 +46,7 @@
  */
 
 /* Works on Always On power domain only (no PD argument) */
-void lpsc_on(unsigned int id)
+static void lpsc_transition(unsigned int id, unsigned int state)
 {
 	dv_reg_p mdstat, mdctl, ptstat, ptcmd;
 #ifdef CONFIG_SOC_DA8XX

arch/arm/cpu/arm926ejs/davinci/psc.c void lpsc_on(unsigned int id) · line 89

Quoted 10 lines
arch/arm/cpu/arm926ejs/davinci/psc.c +3 -3
@@ -83,10 +83,10 @@ void lpsc_on(unsigned int id)
 	while (readl(ptstat) & 0x01)
 		continue;
 
-	if ((readl(mdstat) & 0x3f) == 0x03)
-		return; /* Already on and enabled */
+	if ((readl(mdstat) & 0x3f) == state)
+		return; /* Already in that state */
 
-	writel(readl(mdctl) | 0x03, mdctl);
+	writel((readl(mdctl) & ~0x1f) | state, mdctl);
                                  ^

Shouldn't this be ~0x3f ? And we should use a define instead 0x3f ...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#9 lore raw

PATCH 3/4 arm, davinci: Add function lpsc_syncreset()

Good morning Heiko,
Thanks for reviewing. See my reply below.

Quoted 35 lines · Heiko Schocher
Quoted 34 lines · Christian Riesch

This patch adds a function lpsc_syncreset that allows setting a lpsc module into Sync Reset state.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>

---
?arch/arm/cpu/arm926ejs/davinci/psc.c ? ? ? ? | ? 20 +++++++++++++++----- ?arch/arm/include/asm/arch-davinci/hardware.h | ? ?1 +
?2 files changed, 16 insertions(+), 5 deletions(-)

arch/arm/cpu/arm926ejs/davinci/psc.c +0 -0
index 486adb0..e02d1f6 100644
@@ -46,7 +46,7 @@

? */

?/* Works on Always On power domain only (no PD argument) */

arch/arm/cpu/arm926ejs/davinci/psc.c +1 -1
-void lpsc_on(unsigned int id)
+static void lpsc_transition(unsigned int id, unsigned int state)

?{
? ? ? dv_reg_p mdstat, mdctl, ptstat, ptcmd;
?#ifdef CONFIG_SOC_DA8XX

arch/arm/cpu/arm926ejs/davinci/psc.c +2 -2
@@ -83,10 +83,10 @@ void lpsc_on(unsigned int id)
 ? ? ? while (readl(ptstat) & 0x01)
 ? ? ? ? ? ? ? continue;
 
- ? ? if ((readl(mdstat) & 0x3f) == 0x03)
- ? ? ? ? ? ? return; /* Already on and enabled */
+ ? ? if ((readl(mdstat) & 0x3f) == state)
+ ? ? ? ? ? ? return; /* Already in that state */
 
Quoted 4 lines

arch/arm/cpu/arm926ejs/davinci/psc.c void lpsc_on(unsigned int id) · line 89

Quoted 2 lines
arch/arm/cpu/arm926ejs/davinci/psc.c +1 -1
- ? ? writel(readl(mdctl) | 0x03, mdctl);
+ ? ? writel((readl(mdctl) & ~0x1f) | state, mdctl);

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^
Shouldn't this be ~0x3f ?

I checked the documentation: Actually this should be ~0x07 since the NEXT bitfield (next module state) in the MDCTL register occupies only bits 0..2. The additional bits in the STATE bitfield of the MDSTAT register are used to indicate state transitions.

Quoted 1 line

And we should use a define instead 0x3f ...

Ok, I'll do.

Best regards, Christian

#10 lore raw

PATCH 4/4 arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c

In reply to Christian Riesch

The LPSC functions defined in
arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
are replaced by those already defined in
arch/arm/cpu/arm926ejs/davinci/psc.c.

Cc Heiko Schocher <[email protected]>
Cc Paulraj Sandeep <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c |   96 +----------------------
 1 files changed, 4 insertions(+), 92 deletions(-)
arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c +4 -92
index a6f0178..490ef8f 100644
@@ -153,49 +153,12 @@ int da850_pll_init(struct davinci_pllc_regs *reg, unsigned long pllmult)
 	return 0;
 }
 
-void da850_lpc_transition(unsigned char pscnum, unsigned char module,
-		unsigned char domain, unsigned char state)
-{
-	struct davinci_psc_regs	*reg;
-	dv_reg_p mdstat, mdctl;
-
-	if (pscnum == 0) {
-		reg = davinci_psc0_regs;
-		mdstat = &reg->psc0.mdstat[module];
-		mdctl = &reg->psc0.mdctl[module];
-	} else {
-		reg = davinci_psc1_regs;
-		mdstat = &reg->psc1.mdstat[module];
-		mdctl = &reg->psc1.mdctl[module];
-	}
-
-	/* Wait for any outstanding transition to complete */
-	while ((readl(&reg->ptstat) & (0x00000001 << domain)))
-		;
-
-	/* If we are already in that state, just return */
-	if ((readl(mdstat) & 0x1F) == state)
-		return;
-
-	/* Perform transition */
-	writel((readl(mdctl) & 0xFFFFFFE0) | state, mdctl);
-	setbits_le32(&reg->ptcmd, (0x00000001 << domain));
-
-	/* Wait for transition to complete */
-	while (readl(&reg->ptstat) & (0x00000001 << domain))
-		;
-
-	/* Wait and verify the state */
-	while ((readl(mdstat) & 0x1F) != state)
-		;
-}
-
 int da850_ddr_setup(unsigned int freq)
 {
 	unsigned long	tmp;
 
 	/* Enable the Clock to DDR2/mDDR */
-	da850_lpc_transition(1, 6, 0, PSC_ENABLE);
+	lpsc_on(DAVINCI_LPSC_DDR_EMIF);
 
 	tmp = readl(&davinci_syscfg1_regs->vtpio_ctl);
 	if ((tmp & VTP_POWERDWN) == VTP_POWERDWN) {
@@ -244,9 +207,9 @@ int da850_ddr_setup(unsigned int freq)
 		&dv_ddr2_regs_ctrl->sdrcr);
 
 	/* SyncReset the Clock to EMIF3A SDRAM */
-	da850_lpc_transition(1, 6, 0, PSC_SYNCRESET);
+	lpsc_syncreset(DAVINCI_LPSC_DDR_EMIF);
 	/* Enable the Clock to EMIF3A SDRAM */
-	da850_lpc_transition(1, 6, 0, PSC_ENABLE);
+	lpsc_on(DAVINCI_LPSC_DDR_EMIF);
 
 	/* disable self refresh */
 	clrbits_le32(&dv_ddr2_regs_ctrl->sdrcr, 0xc0000000);
@@ -255,54 +218,6 @@ int da850_ddr_setup(unsigned int freq)
 	return 0;
 }
 
-static void da850_set_mdctl(dv_reg_p mdctl)
-{
-	if ((readl(mdctl) & 0x1F) != PSC_ENABLE)
-		writel(((readl(mdctl) & 0xFFFFFFE0) | PSC_ENABLE), mdctl);
-}
-
-void da850_psc_init(void)
-{
-	struct davinci_psc_regs	*reg;
-	int i;
-
-	/* PSC 0 domain 0 init */
-	reg = davinci_psc0_regs;
-	while ((readl(&reg->ptstat) & 0x00000001))
-		;
-
-	for (i = 3; i <= 4 ; i++)
-		da850_set_mdctl(&reg->psc0.mdctl[i]);
-
-	for (i = 7; i <= 12 ; i++)
-		da850_set_mdctl(&reg->psc0.mdctl[i]);
-
-	/* Do Always-On Power Domain Transitions */
-	setbits_le32(&reg->ptcmd, 0x00000001);
-	while (readl(&reg->ptstat) & 0x00000001)
-		;
-
-	/* PSC1, domain 1 init */
-	reg = davinci_psc1_regs;
-	while ((readl(&reg->ptstat) & 0x00000001))
-		;
-
-	da850_set_mdctl(&reg->psc1.mdctl[3]);
-	da850_set_mdctl(&reg->psc1.mdctl[6]);
-
-	/* UART1 + UART2 */
-	for (i = 12 ; i <= 13 ; i++)
-		da850_set_mdctl(&reg->psc1.mdctl[i]);
-
-	da850_set_mdctl(&reg->psc1.mdctl[26]);
-	da850_set_mdctl(&reg->psc1.mdctl[31]);
-
-	/* Do Always-On Power Domain Transitions */
-	setbits_le32(&reg->ptcmd, 0x00000001);
-	while (readl(&reg->ptstat) & 0x00000001)
-		;
-}
-
 void da850_pinmux_ctl(unsigned long offset, unsigned long mask,
 	unsigned long value)
 {
@@ -368,9 +283,6 @@ int arch_cpu_init(void)
 	dv_maskbits(&davinci_syscfg_regs->suspsrc,
 		((1 << 27) | (1 << 22) | (1 << 20) | (1 << 5) |	(1 << 16)));
 
-	/* System PSC setup - enable all */
-	da850_psc_init();
-
 	/* Setup Pinmux */
 	da850_pinmux_ctl(0, 0xFFFFFFFF, CONFIG_SYS_DA850_PINMUX0);
 	da850_pinmux_ctl(1, 0xFFFFFFFF, CONFIG_SYS_DA850_PINMUX1);
@@ -404,7 +316,7 @@ int arch_cpu_init(void)
 	writel(CONFIG_SYS_DA850_CS2CFG, &davinci_emif_regs->ab1cr);
 	writel(CONFIG_SYS_DA850_CS3CFG, &davinci_emif_regs->ab2cr);
 
-	da850_lpc_transition(1, 13, 0, PSC_ENABLE);
+	lpsc_on(DAVINCI_LPSC_UART2);
 	NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1),
 			CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
 
Signature · 1 line
1.7.0.4
#11 lore raw

cover Remove duplicate functions for power and sleep configuration

In reply to Christian Riesch

Hi,
according to http://lists.denx.de/pipermail/u-boot/2011-October/104965.html
two patches in the prerequisites must be replaced.

Quoted 1 line · Christian Riesch

Prerequisites:

[...]

Quoted 2 lines

[U-Boot] arm, logbuffer: make it compileclean
http://patchwork.ozlabs.org/patch/114740/

Use
[U-Boot,v2] arm, logbuffer: make it compileclean
http://patchwork.ozlabs.org/patch/119183/
instead!

Quoted 2 lines

[U-Boot] cosmetic, post: Codingstyle cleanup
http://patchwork.ozlabs.org/patch/114742/

Use
[U-Boot,v2] cosmetic, post: Codingstyle cleanup
http://patchwork.ozlabs.org/patch/119184/
instead!

Regards, Christian

#12 lore raw

cover Remove duplicate functions for power and sleep configuration

In reply to Christian Riesch

Hello Christian,

Quoted 15 lines · Christian Riesch

Hi,
these patches apply on top of Heiko Schocher's patches for the enbw_cmc board. They remove the duplicate functions for the power and sleep controller of the davinci devices.

The first patch renames the low level configuration functions since they can not only be used for the AM1808 but for the entire da850 family.

The second patch corrects the mask for the state bitfield of the MDSTAT registers. Similar patches have been already submitted for the Linux kernel and other parts of u-boot, see e.g. http://patchwork.ozlabs.org/patch/114942/

Patch number three adds a function to set an LPSC module to Sync Reset state as this is required for DDR memory controller initialization.

Quoted 7 lines

The forth patch finally replaces the PSC related functions in arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c by those of psc.c.

I tested the DDR initialization functions on my board and they worked fine, but of course I can only compile-test them for Heiko's board.

I am looking forward to your comments!

just tried your patches, but after applying it, my console on UART2 is not longer working properly on the enbw_cmc board, it seems, Tx only works ... investigating this behaviour ...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#13 lore raw

cover Remove duplicate functions for power and sleep configuration

Hello Christian,

Quoted 21 lines · Heiko Schocher

Hello Christian,

Quoted 18 lines · Christian Riesch

Hi,
these patches apply on top of Heiko Schocher's patches for the enbw_cmc board. They remove the duplicate functions for the power and sleep controller of the davinci devices.

The first patch renames the low level configuration functions since they can not only be used for the AM1808 but for the entire da850 family.

The second patch corrects the mask for the state bitfield of the MDSTAT registers. Similar patches have been already submitted for the Linux kernel and other parts of u-boot, see e.g. http://patchwork.ozlabs.org/patch/114942/

Patch number three adds a function to set an LPSC module to Sync Reset state as this is required for DDR memory controller initialization.

The forth patch finally replaces the PSC related functions in arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c by those of psc.c.

Quoted 8 lines
Quoted 4 lines

I tested the DDR initialization functions on my board and they worked fine, but of course I can only compile-test them for Heiko's board.

I am looking forward to your comments!

just tried your patches, but after applying it, my console on UART2 is not longer working properly on the enbw_cmc board, it seems, Tx only works ... investigating this behaviour ...

Found it, your code is Ok. If you sent an update version of this patchset, with the issues fixed, I test them on my hardware, thanks!

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany