Remove duplicate functions for power and sleep configuration
Subsystems (2)
v2 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.
Changes for v2:
- use -M option of git format-patch to detect the renaming of files
- Removed one patch of the patchset (arm, davinci: Correct the MDSTAT.STATE mask) since a similar patch was already submitted by Sergei Shtylyov. The prerequisites list below was updated accordingly.
- Use defines for bitmasks for PSC configuration instead of magic numbers.
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.
Patch number two adds a function to set an LPSC module to Sync Reset state as this is required for DDR memory controller initialization.
The third patch finally replaces the PSC related functions in arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c by those of psc.c.
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,v2] arm, logbuffer: make it compileclean
http://patchwork.ozlabs.org/patch/119183/
[U-Boot,v2] cosmetic, post: Codingstyle cleanup
http://patchwork.ozlabs.org/patch/119184/
[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/
[U-Boot,v3] DaVinci: correct MDSTAT.STATE mask
http://patchwork.ozlabs.org/patch/116094/
Regards, Christian
Christian Riesch (3):
arm, davinci: Rename AM1808 lowlevel functions to DA850 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 +-
.../{am1808_lowlevel.c => da850_lowlevel.c} | 202 ++++++--------------
arch/arm/cpu/arm926ejs/davinci/psc.c | 20 ++-
.../{am1808_lowlevel.h => da850_lowlevel.h} | 26 ++--
arch/arm/include/asm/arch-davinci/hardware.h | 2 +
board/enbw/enbw_cmc/enbw_cmc.c | 2 +-
include/configs/enbw_cmc.h | 92 +++++-----
7 files changed, 135 insertions(+), 211 deletions(-)
rename arch/arm/cpu/arm926ejs/davinci/{am1808_lowlevel.c => da850_lowlevel.c} (57%)
rename arch/arm/include/asm/arch-davinci/{am1808_lowlevel.h => da850_lowlevel.h} (63%)PATCH v2 1/3 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.
---
arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +-
.../{am1808_lowlevel.c => da850_lowlevel.c} | 136 ++++++++++----------
.../{am1808_lowlevel.h => da850_lowlevel.h} | 26 ++--
board/enbw/enbw_cmc/enbw_cmc.c | 2 +-
include/configs/enbw_cmc.h | 92 +++++++-------
5 files changed, 129 insertions(+), 129 deletions(-)
rename arch/arm/cpu/arm926ejs/davinci/{am1808_lowlevel.c => da850_lowlevel.c} (70%)
rename arch/arm/include/asm/arch-davinci/{am1808_lowlevel.h => da850_lowlevel.h} (63%)arch/arm/cpu/arm926ejs/davinci/Makefile +1 -1
@@ -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/da850_lowlevel.c renamed from arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.c +68 -68
292 lines not on this page · raw message
arch/arm/include/asm/arch-davinci/da850_lowlevel.h renamed from arch/arm/include/asm/arch-davinci/am1808_lowlevel.h +13 -13
@@ -1,5 +1,5 @@/* -* SoC-specific lowlevel code for AM1808 and similar chips +* SoC-specific lowlevel code for DA850 * * Copyright (C) 2011 * Heiko Schocher, DENX Software Engineering, hs at denx.de.
@@ -21,24 +21,24 @@* along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __AM1808_LOWLEVEL_H -#define __AM1808_LOWLEVEL_H +#ifndef __DA850_LOWLEVEL_H +#define __DA850_LOWLEVEL_H/* NOR Boot Configuration Word Field Descriptions */ -#define AM1808_NORBOOT_COPY_XK (X ) ((X - 1) << 8) -#define AM1808_NORBOOT_METHOD_DIRECT (1 << 4) -#define AM1808_NORBOOT_16BIT (1 << 0) +#define DA850_NORBOOT_COPY_XK (X ) ((X - 1) << 8) +#define DA850_NORBOOT_METHOD_DIRECT (1 << 4) +#define DA850_NORBOOT_16BIT (1 << 0)#define dv_maskbits (addr, val) \ writel((readl(addr) & val), addr) -void am1808_waitloop (unsigned long loopcnt); -int am1808_pll_init (struct davinci_pllc_regs *reg,unsigned long pllmult); -void am1808_lpc_transition (unsigned char pscnum,unsigned char module, +void da850_waitloop (unsigned long loopcnt); +int da850_pll_init (struct davinci_pllc_regs *reg,unsigned long pllmult); +void da850_lpc_transition (unsigned char pscnum,unsigned char module,unsigned char domain,unsigned char state); -int am1808_ddr_setup (unsigned int freq); -void am1808_psc_init (void ); -void am1808_pinmux_ctl (unsigned long offset,unsigned long mask, +int da850_ddr_setup (unsigned int freq); +void da850_psc_init (void ); +void da850_pinmux_ctl (unsigned long offset,unsigned long mask,unsigned long value); -#endif /* #ifndef __AM1808_LOWLEVEL_H */ +#endif /* #ifndef __DA850_LOWLEVEL_H */
board/enbw/enbw_cmc/enbw_cmc.c +1 -1
@@ -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
PATCH v2 1/3 arm, davinci: Rename AM1808 lowlevel functions to DA850
Hello Christian,
Quoted 10 lines · Christian Riesch
Rename
arch/arm/cpu/arm926ejs/davinci/am1808_lowlevel.candarch/arm/include/asm/arch-davinci/am1808_lowlevel.htoda850_lowlevel.candda850_lowlevel.hsince they apply not only to the AM1808 SoC but to all DA850 chips. The function names and #defines are changed likewise.Signed-off-by Christian Riesch <[email protected]>Cc Heiko Schocher <[email protected]>Cc Paulraj Sandeep <[email protected]>Cc Albert ARIBAUD <[email protected]>
Quoted 9 lines
---
arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +-
.../{am1808_lowlevel.c => da850_lowlevel.c} | 136 ++++++++++----------
.../{am1808_lowlevel.h => da850_lowlevel.h} | 26 ++--
board/enbw/enbw_cmc/enbw_cmc.c | 2 +-
include/configs/enbw_cmc.h | 92 +++++++-------
5 files changed, 129 insertions(+), 129 deletions(-)
rename arch/arm/cpu/arm926ejs/davinci/{am1808_lowlevel.c => da850_lowlevel.c} (70%)
rename arch/arm/include/asm/arch-davinci/{am1808_lowlevel.h => da850_lowlevel.h} (63%)Tested on the enbw_cmc board, so:
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
PATCH v2 2/3 arm, davinci: Add function lpsc_syncreset()
In reply to Christian RieschThis patch adds a function lpsc_syncreset that allows setting a lpsc module into Sync Reset state.
--- arch/arm/cpu/arm926ejs/davinci/psc.c | 20 +++++++++++++++----- arch/arm/include/asm/arch-davinci/hardware.h | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-)
arch/arm/cpu/arm926ejs/davinci/psc.c +15 -5
@@ -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) &PSC_MDSTAT_STATE ) ==0x03 ) -return ;/* Already on and enabled */ +if ((readl (mdstat) &PSC_MDSTAT_STATE ) == state) +return ;/* Already in that state */ -writel (readl (mdctl) |0x03 , mdctl); +writel ((readl (mdctl) & ~PSC_MDCTL_NEXT ) | 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) &PSC_MDSTAT_STATE ) !=0x03 ) +while ((readl (mdstat) &PSC_MDSTAT_STATE ) != 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 +2 -0
@@ -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 );
@@ -357,6 +358,7 @@ struct davinci_psc_regs {#endif /* CONFIG_SOC_DA8XX */ #define PSC_MDSTAT_STATE 0x3f +#define PSC_MDCTL_NEXT 0x07#ifndef CONFIG_SOC_DA8XX
Signature · 1 line
1.7.0.4
PATCH v2 2/3 arm, davinci: Add function lpsc_syncreset()
Hello Christian,
Quoted 11 lines · Christian Riesch
This patch adds a function
lpsc_syncresetthat allows setting a lpsc module into Sync Reset state.Signed-off-by Christian Riesch <[email protected]>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 | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-)
Tested on the enbw_cmc board, so:
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
PATCH v2 3/3 arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c
In reply to Christian RieschThe LPSC functions defined inarch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
are replaced by those already defined inarch/arm/cpu/arm926ejs/davinci/psc.c.
--- 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
@@ -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 = ®->psc0.mdstat[module]; - mdctl = ®->psc0.mdctl[module]; - }else { - reg = davinci_psc1_regs; - mdstat = ®->psc1.mdstat[module]; - mdctl = ®->psc1.mdctl[module]; - } - -/* Wait for any outstanding transition to complete */ -while ((readl (®->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 (®->ptcmd, (0x00000001 << domain)); - -/* Wait for transition to complete */ -while (readl (®->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 (®->ptstat) &0x00000001 )) - ; - -for (i =3 ; i <=4 ; i++) -da850_set_mdctl (®->psc0.mdctl[i]); - -for (i =7 ; i <=12 ; i++) -da850_set_mdctl (®->psc0.mdctl[i]); - -/* Do Always-On Power Domain Transitions */ -setbits_le32 (®->ptcmd,0x00000001 ); -while (readl (®->ptstat) &0x00000001 ) - ; - -/* PSC1, domain 1 init */ - reg = davinci_psc1_regs; -while ((readl (®->ptstat) &0x00000001 )) - ; - -da850_set_mdctl (®->psc1.mdctl[3 ]); -da850_set_mdctl (®->psc1.mdctl[6 ]); - -/* UART1 + UART2 */ -for (i =12 ; i <=13 ; i++) -da850_set_mdctl (®->psc1.mdctl[i]); - -da850_set_mdctl (®->psc1.mdctl[26 ]); -da850_set_mdctl (®->psc1.mdctl[31 ]); - -/* Do Always-On Power Domain Transitions */ -setbits_le32 (®->ptcmd,0x00000001 ); -while (readl (®->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
PATCH v2 3/3 arm, davinci: Remove the duplication of LPSC functions in da850_lowlevel.c
Hello Christian,
Quoted 5 lines · Christian Riesch
The LPSC functions defined in
arch/arm/cpu/arm926ejs/davinci/da850_lowlevel.c
are replaced by those already defined inarch/arm/cpu/arm926ejs/davinci/psc.c.
Quoted 7 lines
Signed-off-by Christian Riesch <[email protected]>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(-)
Tested on the enbw_cmc board, so:
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