[U-Boot] [PATCH 0/4] SMDK5250: Convert lowlevel_init.S to .c and set PMIC values

This patch converts lowlevel_init.S to lowlevel_init_c.c. Add PMIC MAX77686 voltage settings for SMDK5250.
Rajeshwari Shinde (4): SMDK5250: Convert lowlevel_init.S to lowlevel_init_c.c EXYNOS: Add functions for power initialisation SMDK5250: Add PMIC voltage settings SMDK5250: Modify IRAM stack pointer address
arch/arm/cpu/armv7/exynos/power.c | 34 ++++++++++++++ arch/arm/include/asm/arch-exynos/power.h | 5 ++ board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/smdk5250.c | 68 ++++++++++++++++++++++++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- include/configs/exynos5250-dt.h | 7 ++- include/power/max77686_pmic.h | 15 ++++++ spl/Makefile | 4 ++ 13 files changed, 266 insertions(+), 86 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c

This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset) { struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call below */ if (param->mem_type == DDR_MODE_DDR3) { - ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size); + ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size, mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1) diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size, + int mem_reset) { unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
- reset_phy_ctrl(); + if (mem_reset) + reset_phy_ctrl();
/* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) | diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE: - .word CONFIG_SYS_TEXT_BASE - .globl lowlevel_init lowlevel_init: - - /* use iRAM stack in bl2 */ - ldr sp, =CONFIG_IRAM_STACK - stmdb r13!, {ip,lr} - - /* check reset status */ - ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET) - ldr r1, [r0] - - /* AFTR wakeup reset */ - ldr r2, =S5P_CHECK_DIDLE - cmp r1, r2 - beq exit_wakeup - - /* LPA wakeup reset */ - ldr r2, =S5P_CHECK_LPA - cmp r1, r2 - beq exit_wakeup - - /* Sleep wakeup reset */ - ldr r2, =S5P_CHECK_SLEEP - cmp r1, r2 - beq wakeup_reset - /* - * If U-boot is already running in RAM, no need to relocate U-Boot. - * Memory controller must be configured before relocating U-Boot - * in ram. + * Set the stack pointer, although it will be overwriten by the caller + * It seems we will not boot if this function is empty. */ - ldr r0, =0x0ffffff /* r0 <- Mask Bits*/ - bic r1, pc, r0 /* pc <- current addr of code */ - /* r1 <- unmasked bits of pc */ - ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */ - bic r2, r2, r0 /* r2 <- unmasked bits of r2*/ - cmp r1, r2 /* compare r1, r2 */ - beq 1f /* r0 == r1 then skip sdram init */ - - /* init system clock */ - bl system_clock_init - - /* Memory initialize */ - bl mem_ctrl_init - -1: - bl tzpc_init - ldmia r13!, {ip,pc} - -wakeup_reset: - bl system_clock_init - bl mem_ctrl_init - bl tzpc_init - -exit_wakeup: - /* Load return address and jump to kernel */ - ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET) - - /* r1 = physical address of exynos5_cpu_resume function*/ - ldr r1, [r0] - - /* Jump to kernel */ - mov pc, r1 - nop - nop + ldr sp, =CONFIG_IRAM_STACK + mov pc, lr diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c @@ -0,0 +1,70 @@ +/* + * Lowlevel setup for SMDK5250 board based on S5PC520 + * + * Copyright (C) 2012 Samsung Electronics + * Copyright (c) 2012 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h" + +/* These are the things we can do during low-level init */ +enum { + DO_WAKEUP = 1 << 0, + DO_CLOCKS = 1 << 1, + DO_MEM_RESET = 1 << 2, +}; + +int lowlevel_init_subsystems(void) +{ + uint32_t reset_status; + int actions = 0; + + arch_cpu_init(); + + reset_status = power_read_reset_status(); + + switch (reset_status) { + case EXYNOS_CHECK_SLEEP: + actions = DO_CLOCKS | DO_WAKEUP; + break; + case EXYNOS_CHECK_DIDLE: + case EXYNOS_CHECK_LPA: + actions = DO_WAKEUP; + break; + default: + /* This is a normal boot (not a wake from sleep) */ + actions = DO_CLOCKS | DO_MEM_RESET; + } + + if (actions & DO_CLOCKS) { + system_clock_init(); + mem_ctrl_init(actions & DO_MEM_RESET); + tzpc_init(); + } + + return actions & DO_WAKEUP; +} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000 + /* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum { * accesses; may vary across boards. * @return 0 if ok, SETUP_ERR_... if there is a problem */ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size, + int mem_reset);
/* * Configure ZQ I/O interface @@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset); void system_clock_init(void); void tzpc_init(void); + +/** + * Init subsystems according to the reset status + * + * @return 0 for a normal boot, non-zero for a resume + */ +int lowlevel_init_subsystems(void); #endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@ * MA 02111-1307 USA */
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode { - BOOT_MODE_MMC = 4, - BOOT_MODE_SERIAL = 20, - /* Boot based on Operating Mode pin settings */ - BOOT_MODE_OM = 32, - BOOT_MODE_USB, /* Boot using USB download */ -}; +DECLARE_GLOBAL_DATA_PTR;
- typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst); +typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/* * Copy U-boot from mmc to RAM: @@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{ + char *ptr = s; + size_t i; + + for (i = 0; i < n; i++) + *ptr++ = '\0'; +} + +/** + * Set up the U-Boot global_data pointer + * + * This sets the address of the global data, and sets up basic values. + * + * @param gdp Value to give to gd + */ +static void setup_global_data(gd_t *gdp) +{ + gd = gdp; + memzero((void *)gd, sizeof(gd_t)); + gd->flags |= GD_FLG_RELOC; + gd->baudrate = CONFIG_BAUDRATE; + gd->have_console = 1; +} + void board_init_f(unsigned long bootflag) { + __attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void); + + setup_global_data(&local_gd); + + if (lowlevel_init_subsystems()) + power_exit_wakeup(); + copy_uboot_to_ram();
/* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)(); + /* Never returns Here */ + panic("%s: u-boot jump failed", __func__); }
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif + ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o

Hi Rajeshwari,
On Fri, Dec 28, 2012 at 4:08 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
Great to see this!
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset) { struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size, mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1)
diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate U-Boot.
* Memory controller must be configured before relocating U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by the caller
overwritten
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init */
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c @@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
No early serial support yet?
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
Are these used in this patch? Are these register values? Please can you add a comment as to what these values are for?
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset);
Please add a comment for this parameter
void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void); #endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
Does this function exist in this patch?
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
Regards, Simon

Hi Simon Glass,
Thank you for comments.
On Fri, Dec 28, 2012 at 8:47 PM, Simon Glass sjg@chromium.org wrote:
Hi Rajeshwari,
On Fri, Dec 28, 2012 at 4:08 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
Great to see this!
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset) { struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size, mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1)
diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate U-Boot.
* Memory controller must be configured before relocating U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by the caller
overwritten
- Will correct this.
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init */
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c @@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
No early serial support yet?
- OK will add it in next version of patch set.
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
Are these used in this patch? Are these register values? Please can you add a comment as to what these values are for?
- Yes they are used in lowlevel_init_c.c. Will add comments.
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset);
Please add a comment for this parameter
- OK
void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void); #endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
Does this function exist in this patch?
- I have added the power related functions in patch 2.
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
-- Regards, Rajeshwari Shinde

On Fri, Dec 28, 2012 at 9:08 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset)
does 'reset' is enough?
{ struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size, mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1)
diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
ditto
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
if (reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate U-Boot.
* Memory controller must be configured before relocating U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by the caller
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init */
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c
lowlevel_init.c?
@@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
These can be uses other exynos5250 series. so can you place it common header file?
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset); void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void);
do_lowlevle_init?
Thank you, Kyungmin Park
#endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Kyungmin Park,
Thank you for comments.
On Mon, Dec 31, 2012 at 6:02 PM, Kyungmin Park kmpark@infradead.org wrote:
On Fri, Dec 28, 2012 at 9:08 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset)
does 'reset' is enough?
- OK
{ struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size, mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1)
diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
ditto
-OK
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
if (reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate U-Boot.
* Memory controller must be configured before relocating U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by the caller
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init */
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c
lowlevel_init.c?
- We get multiple definition of `lowlevel_init' error if we name as lowlevel_init.c.
@@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
These can be uses other exynos5250 series. so can you place it common header file?
- Would it be ok if I place this in arch/arm/include/asm/arch-exynos/power.h ?
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset); void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void);
do_lowlevle_init?
- OK
Thank you, Kyungmin Park
#endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi,
On 1/2/13, Rajeshwari Birje rajeshwari.birje@gmail.com wrote:
Hi Kyungmin Park,
Thank you for comments.
On Mon, Dec 31, 2012 at 6:02 PM, Kyungmin Park kmpark@infradead.org wrote:
On Fri, Dec 28, 2012 at 9:08 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset)
does 'reset' is enough?
- OK
{ struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call
below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size,
mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1) diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
ditto
-OK
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
if (reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate
U-Boot.
* Memory controller must be configured before relocating U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by the
caller
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
ldr r2, _TEXT_BASE /* r2 <- original base addr in
ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init
*/
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c
lowlevel_init.c?
- We get multiple definition of `lowlevel_init' error if we name as
lowlevel_init.c.
It's filename, and function name is used as do_lowlevel_init. doesn't it?
@@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
These can be uses other exynos5250 series. so can you place it common header file?
- Would it be ok if I place this in arch/arm/include/asm/arch-exynos/power.h
?
yes, and proper prefix, EXYNOS5 or EXYNOS5250. BTW can be use it at exynos4 series?
Thank you, Kyungmin Park
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset); void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void);
do_lowlevle_init?
- OK
Thank you, Kyungmin Park
#endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
-- Regards, Rajeshwari Shinde

Hi Kyungmin Park,
On Wed, Jan 2, 2013 at 11:48 AM, Kyungmin Park kmpark@infradead.org wrote:
Hi,
On 1/2/13, Rajeshwari Birje rajeshwari.birje@gmail.com wrote:
Hi Kyungmin Park,
Thank you for comments.
On Mon, Dec 31, 2012 at 6:02 PM, Kyungmin Park kmpark@infradead.org wrote:
On Fri, Dec 28, 2012 at 9:08 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset)
does 'reset' is enough?
- OK
{ struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call
below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size,
mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1) diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
ditto
-OK
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
if (reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate
U-Boot.
* Memory controller must be configured before relocating U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by the
caller
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
ldr r2, _TEXT_BASE /* r2 <- original base addr in
ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init
*/
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c
lowlevel_init.c?
- We get multiple definition of `lowlevel_init' error if we name as
lowlevel_init.c.
It's filename, and function name is used as do_lowlevel_init. doesn't it?
- Yes but we also have a lowlevel_init.S which will have a object file lowlevel_init.o and if we name file as lowlevel_init.c it will also have lowlevel_init.o and it will lead to error.
@@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
These can be uses other exynos5250 series. so can you place it common header file?
- Would it be ok if I place this in arch/arm/include/asm/arch-exynos/power.h
?
yes, and proper prefix, EXYNOS5 or EXYNOS5250. BTW can be use it at exynos4 series?
Thank you, Kyungmin Park
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset); void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void);
do_lowlevle_init?
- OK
Thank you, Kyungmin Park
#endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
+typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
-- Regards, Rajeshwari Shinde

On 1/2/13, Rajeshwari Birje rajeshwari.birje@gmail.com wrote:
Hi Kyungmin Park,
On Wed, Jan 2, 2013 at 11:48 AM, Kyungmin Park kmpark@infradead.org wrote:
Hi,
On 1/2/13, Rajeshwari Birje rajeshwari.birje@gmail.com wrote:
Hi Kyungmin Park,
Thank you for comments.
On Mon, Dec 31, 2012 at 6:02 PM, Kyungmin Park kmpark@infradead.org wrote:
On Fri, Dec 28, 2012 at 9:08 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch converts lowlevel_init.S to lowlevel_init_c.c for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/Makefile | 1 + board/samsung/smdk5250/dmc_common.c | 4 +- board/samsung/smdk5250/dmc_init_ddr3.c | 6 ++- board/samsung/smdk5250/lowlevel_init.S | 69 ++--------------------------- board/samsung/smdk5250/lowlevel_init_c.c | 70 ++++++++++++++++++++++++++++++ board/samsung/smdk5250/setup.h | 17 ++++++- board/samsung/smdk5250/spl_boot.c | 52 ++++++++++++++++++---- spl/Makefile | 4 ++ 8 files changed, 142 insertions(+), 81 deletions(-) create mode 100644 board/samsung/smdk5250/lowlevel_init_c.c
diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index 47c6a5a..b99ac7f 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -37,6 +37,7 @@ endif
ifdef CONFIG_SPL_BUILD COBJS += spl_boot.o +COBJS += lowlevel_init_c.o endif
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/board/samsung/smdk5250/dmc_common.c b/board/samsung/smdk5250/dmc_common.c index 109602a..6a26822 100644 --- a/board/samsung/smdk5250/dmc_common.c +++ b/board/samsung/smdk5250/dmc_common.c @@ -175,7 +175,7 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc) writel(DMC_MEMBASECONFIG1_VAL, &dmc->membaseconfig1); }
-void mem_ctrl_init() +void mem_ctrl_init(int mem_reset)
does 'reset' is enough?
- OK
{ struct spl_machine_param *param = spl_get_machine_params(); struct mem_timings *mem; @@ -185,7 +185,7 @@ void mem_ctrl_init()
/* If there are any other memory variant, add their init call
below */ if (param->mem_type == DDR_MODE_DDR3) {
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size);
ret = ddr3_mem_ctrl_init(mem, param->mem_iv_size,
mem_reset); if (ret) { /* will hang if failed to init memory control */ while (1) diff --git a/board/samsung/smdk5250/dmc_init_ddr3.c b/board/samsung/smdk5250/dmc_init_ddr3.c index e050790..4e0693d 100644 --- a/board/samsung/smdk5250/dmc_init_ddr3.c +++ b/board/samsung/smdk5250/dmc_init_ddr3.c @@ -40,7 +40,8 @@ static void reset_phy_ctrl(void) writel(DDR3PHY_CTRL_PHY_RESET, &clk->lpddr3phy_ctrl); }
-int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset)
ditto
-OK
{ unsigned int val; struct exynos5_phy_control *phy0_ctrl, *phy1_ctrl; @@ -51,7 +52,8 @@ int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size) phy1_ctrl = (struct exynos5_phy_control *)EXYNOS5_DMC_PHY1_BASE; dmc = (struct exynos5_dmc *)EXYNOS5_DMC_CTRL_BASE;
reset_phy_ctrl();
if (mem_reset)
if (reset)
reset_phy_ctrl(); /* Set Impedance Output Driver */ val = (mem->impedance << CA_CK_DRVR_DS_OFFSET) |
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S index bc6cb6f..469126d 100644 --- a/board/samsung/smdk5250/lowlevel_init.S +++ b/board/samsung/smdk5250/lowlevel_init.S @@ -23,74 +23,13 @@ */
#include <config.h> -#include <version.h> #include <asm/arch/cpu.h>
-_TEXT_BASE:
.word CONFIG_SYS_TEXT_BASE
.globl lowlevel_init
lowlevel_init:
/* use iRAM stack in bl2 */
ldr sp, =CONFIG_IRAM_STACK
stmdb r13!, {ip,lr}
/* check reset status */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET)
ldr r1, [r0]
/* AFTR wakeup reset */
ldr r2, =S5P_CHECK_DIDLE
cmp r1, r2
beq exit_wakeup
/* LPA wakeup reset */
ldr r2, =S5P_CHECK_LPA
cmp r1, r2
beq exit_wakeup
/* Sleep wakeup reset */
ldr r2, =S5P_CHECK_SLEEP
cmp r1, r2
beq wakeup_reset
/*
* If U-boot is already running in RAM, no need to relocate
U-Boot.
* Memory controller must be configured before relocating
U-Boot
* in ram.
* Set the stack pointer, although it will be overwriten by
the caller
* It seems we will not boot if this function is empty. */
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code
*/
/* r1 <- unmasked bits of pc
*/
ldr r2, _TEXT_BASE /* r2 <- original base addr in
ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram
init */
/* init system clock */
bl system_clock_init
/* Memory initialize */
bl mem_ctrl_init
-1:
bl tzpc_init
ldmia r13!, {ip,pc}
-wakeup_reset:
bl system_clock_init
bl mem_ctrl_init
bl tzpc_init
-exit_wakeup:
/* Load return address and jump to kernel */
ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET)
/* r1 = physical address of exynos5_cpu_resume function*/
ldr r1, [r0]
/* Jump to kernel */
mov pc, r1
nop
nop
ldr sp, =CONFIG_IRAM_STACK
mov pc, lr
diff --git a/board/samsung/smdk5250/lowlevel_init_c.c b/board/samsung/smdk5250/lowlevel_init_c.c new file mode 100644 index 0000000..fdb98cf --- /dev/null +++ b/board/samsung/smdk5250/lowlevel_init_c.c
lowlevel_init.c?
- We get multiple definition of `lowlevel_init' error if we name as
lowlevel_init.c.
It's filename, and function name is used as do_lowlevel_init. doesn't it?
- Yes but we also have a lowlevel_init.S which will have a object file
lowlevel_init.o and if we name file as lowlevel_init.c it will also have lowlevel_init.o and it will lead to error.
Okay, I assume we already have common lowlevel_init at common directory as others. but exynos doesn't.
So how about to add common codes and use it? you can refer it as omap did.
Thank you, Kyungmin Park
# git grep lowlevel arch/arm/cpu/armv7/ arch/arm/cpu/armv7/Makefile:SOBJS += lowlevel_init.o arch/arm/cpu/armv7/lowlevel_init.S: * A lowlevel_init function that sets up the arch/arm/cpu/armv7/lowlevel_init.S:ENTRY(lowlevel_init) arch/arm/cpu/armv7/lowlevel_init.S:ENDPROC(lowlevel_init) arch/arm/cpu/armv7/mx5/Makefile:SOBJS = lowlevel_init.o arch/arm/cpu/armv7/mx5/lowlevel_init.S:ENTRY(lowlevel_init) arch/arm/cpu/armv7/mx5/lowlevel_init.S:ENDPROC(lowlevel_init) arch/arm/cpu/armv7/mx6/Makefile:SOBJS = lowlevel_init.o arch/arm/cpu/armv7/mx6/lowlevel_init.S:ENTRY(lowlevel_init) arch/arm/cpu/armv7/mx6/lowlevel_init.S:ENDPROC(lowlevel_init) arch/arm/cpu/armv7/omap-common/Makefile:SOBJS += lowlevel_init.o arch/arm/cpu/armv7/omap3/Makefile:SOBJS := lowlevel_init.o arch/arm/cpu/armv7/omap3/lowlevel_init.S:ENTRY(lowlevel_init) arch/arm/cpu/armv7/omap3/lowlevel_init.S:ENDPROC(lowlevel_init) arch/arm/cpu/armv7/rmobile/Makefile:SOBJS = lowlevel_init.o arch/arm/cpu/armv7/rmobile/lowlevel_init.S:ENTRY(lowlevel_init) arch/arm/cpu/armv7/rmobile/lowlevel_init.S: beq lowlevel_init__ arch/arm/cpu/armv7/rmobile/lowlevel_init.S:lowlevel_init__: arch/arm/cpu/armv7/rmobile/lowlevel_init.S:ENDPROC(lowlevel_init) arch/arm/cpu/armv7/socfpga/Makefile:SOBJS := lowlevel_init.o arch/arm/cpu/armv7/socfpga/lowlevel_init.S:.globl lowlevel_init arch/arm/cpu/armv7/socfpga/lowlevel_init.S:lowlevel_init: arch/arm/cpu/armv7/start.S: b lowlevel_init @ go setup pll,m arch/arm/cpu/armv7/u8500/Makefile:SOBJS = lowlevel.o arch/arm/cpu/armv7/u8500/lowlevel.S:ENTRY(lowlevel_init) arch/arm/cpu/armv7/u8500/lowlevel.S:ENDPROC(lowlevel_init) arch/arm/cpu/armv7/zynq/cpu.c:inline void lowlevel_init(void) {}
@@ -0,0 +1,70 @@ +/*
- Lowlevel setup for SMDK5250 board based on S5PC520
- Copyright (C) 2012 Samsung Electronics
- Copyright (c) 2012 The Chromium OS Authors.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+#include <common.h> +#include <config.h> +#include <asm/arch/cpu.h> +#include <asm/arch/dmc.h> +#include <asm/arch/power.h> +#include <asm/arch/tzpc.h> +#include "setup.h"
+/* These are the things we can do during low-level init */ +enum {
DO_WAKEUP = 1 << 0,
DO_CLOCKS = 1 << 1,
DO_MEM_RESET = 1 << 2,
+};
+int lowlevel_init_subsystems(void) +{
uint32_t reset_status;
int actions = 0;
arch_cpu_init();
reset_status = power_read_reset_status();
switch (reset_status) {
case EXYNOS_CHECK_SLEEP:
actions = DO_CLOCKS | DO_WAKEUP;
break;
case EXYNOS_CHECK_DIDLE:
case EXYNOS_CHECK_LPA:
actions = DO_WAKEUP;
break;
default:
/* This is a normal boot (not a wake from sleep) */
actions = DO_CLOCKS | DO_MEM_RESET;
}
if (actions & DO_CLOCKS) {
system_clock_init();
mem_ctrl_init(actions & DO_MEM_RESET);
tzpc_init();
}
return actions & DO_WAKEUP;
+} diff --git a/board/samsung/smdk5250/setup.h b/board/samsung/smdk5250/setup.h index a159601..d64e385 100644 --- a/board/samsung/smdk5250/setup.h +++ b/board/samsung/smdk5250/setup.h @@ -28,6 +28,11 @@ #include <config.h> #include <asm/arch/dmc.h>
+/* Power Down Modes */ +#define EXYNOS_CHECK_SLEEP 0x00000BAD +#define EXYNOS_CHECK_DIDLE 0xBAD00000 +#define EXYNOS_CHECK_LPA 0xABAD0000
These can be uses other exynos5250 series. so can you place it common header file?
- Would it be ok if I place this in
arch/arm/include/asm/arch-exynos/power.h ?
yes, and proper prefix, EXYNOS5 or EXYNOS5250. BTW can be use it at exynos4 series?
Thank you, Kyungmin Park
/* TZPC : Register Offsets */ #define TZPC0_BASE 0x10100000 #define TZPC1_BASE 0x10110000 @@ -539,7 +544,8 @@ enum {
accesses; may vary across boards.
- @return 0 if ok, SETUP_ERR_... if there is a problem
*/ -int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size); +int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
int mem_reset);
/*
- Configure ZQ I/O interface
@@ -588,7 +594,14 @@ void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc); void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
void sdelay(unsigned long); -void mem_ctrl_init(void); +void mem_ctrl_init(int mem_reset); void system_clock_init(void); void tzpc_init(void);
+/**
- Init subsystems according to the reset status
- @return 0 for a normal boot, non-zero for a resume
- */
+int lowlevel_init_subsystems(void);
do_lowlevle_init?
- OK
Thank you, Kyungmin Park
#endif diff --git a/board/samsung/smdk5250/spl_boot.c b/board/samsung/smdk5250/spl_boot.c index d8f3c1e..66bce5b 100644 --- a/board/samsung/smdk5250/spl_boot.c +++ b/board/samsung/smdk5250/spl_boot.c @@ -20,18 +20,16 @@
- MA 02111-1307 USA
*/
-#include<common.h> -#include<config.h> +#include <common.h> +#include <config.h> +#include <asm/arch/spl.h> +#include <asm/arch/cpu.h> +#include <asm/arch/power.h> +#include "setup.h"
-enum boot_mode {
BOOT_MODE_MMC = 4,
BOOT_MODE_SERIAL = 20,
/* Boot based on Operating Mode pin settings */
BOOT_MODE_OM = 32,
BOOT_MODE_USB, /* Boot using USB download */
-}; +DECLARE_GLOBAL_DATA_PTR;
typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32
dst); +typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
/*
- Copy U-boot from mmc to RAM:
@@ -62,15 +60,49 @@ void copy_uboot_to_ram(void) } }
+void memzero(void *s, size_t n) +{
char *ptr = s;
size_t i;
for (i = 0; i < n; i++)
*ptr++ = '\0';
+}
+/**
- Set up the U-Boot global_data pointer
- This sets the address of the global data, and sets up basic
values.
- @param gdp Value to give to gd
- */
+static void setup_global_data(gd_t *gdp) +{
gd = gdp;
memzero((void *)gd, sizeof(gd_t));
gd->flags |= GD_FLG_RELOC;
gd->baudrate = CONFIG_BAUDRATE;
gd->have_console = 1;
+}
void board_init_f(unsigned long bootflag) {
__attribute__((aligned(8))) gd_t local_gd; __attribute__((noreturn)) void (*uboot)(void);
setup_global_data(&local_gd);
if (lowlevel_init_subsystems())
power_exit_wakeup();
copy_uboot_to_ram(); /* Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_TEXT_BASE; (*uboot)();
/* Never returns Here */
panic("%s: u-boot jump failed", __func__);
}
/* Place Holders */ diff --git a/spl/Makefile b/spl/Makefile index 6dbb105..3aab466 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -86,6 +86,10 @@ ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS-y += $(CPUDIR)/omap-common/libomap-common.o endif
+ifneq ($(CONFIG_EXYNOS4)$(CONFIG_EXYNOS5),) +LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o +endif
ifeq ($(SOC),tegra20) LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o -- 1.7.4.4
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
-- Regards, Rajeshwari Shinde
-- Regards, Rajeshwari Shinde

This patch adds functions to intialsise power registers during spl boot.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- arch/arm/cpu/armv7/exynos/power.c | 34 ++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-exynos/power.h | 5 ++++ 2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv7/exynos/power.c b/arch/arm/cpu/armv7/exynos/power.c index d4bce6d..8ab43f4 100644 --- a/arch/arm/cpu/armv7/exynos/power.c +++ b/arch/arm/cpu/armv7/exynos/power.c @@ -22,8 +22,15 @@ */
#include <common.h> +#include <errno.h> +#include <i2c.h> #include <asm/io.h> #include <asm/arch/power.h> +#include <asm/arch/spl.h> +#include <power/max77686_pmic.h> +#include <power/pmic.h> +#include <asm/arch/periph.h> +#include <asm/arch/pinmux.h>
static void exynos4_mipi_phy_control(unsigned int dev_index, unsigned int enable) @@ -95,3 +102,30 @@ void set_dp_phy_ctrl(unsigned int enable) if (cpu_is_exynos5()) exynos5_dp_phy_control(enable); } + +uint32_t power_read_reset_status(void) +{ + struct exynos5_power *power = + (struct exynos5_power *)samsung_get_base_power(); + + return power->inform1; +} + +void ps_hold_setup(void) +{ + struct exynos5_power *power = + (struct exynos5_power *)samsung_get_base_power(); + + /* Set PS-Hold high */ + setbits_le32(&power->ps_hold_control, + EXYNOS_PS_HOLD_CONTROL_DATA_HIGH); +} + +void power_exit_wakeup(void) +{ + struct exynos5_power *power = + (struct exynos5_power *)samsung_get_base_power(); + typedef void (*resume_func)(void); + + ((resume_func)power->inform0)(); +} diff --git a/arch/arm/include/asm/arch-exynos/power.h b/arch/arm/include/asm/arch-exynos/power.h index d2fdb59..3e83f55 100644 --- a/arch/arm/include/asm/arch-exynos/power.h +++ b/arch/arm/include/asm/arch-exynos/power.h @@ -864,4 +864,9 @@ void set_dp_phy_ctrl(unsigned int enable);
#define EXYNOS_DP_PHY_ENABLE (1 << 0)
+#define EXYNOS_PS_HOLD_CONTROL_DATA_HIGH (1 << 8) + +uint32_t power_read_reset_status(void); +void ps_hold_setup(void); +void power_exit_wakeup(void); #endif

Hi Rajeshwari,
On Fri, Dec 28, 2012 at 4:08 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch adds functions to intialsise power registers during spl boot.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
arch/arm/cpu/armv7/exynos/power.c | 34 ++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-exynos/power.h | 5 ++++ 2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv7/exynos/power.c b/arch/arm/cpu/armv7/exynos/power.c index d4bce6d..8ab43f4 100644 --- a/arch/arm/cpu/armv7/exynos/power.c +++ b/arch/arm/cpu/armv7/exynos/power.c @@ -22,8 +22,15 @@ */
#include <common.h> +#include <errno.h> +#include <i2c.h> #include <asm/io.h> #include <asm/arch/power.h> +#include <asm/arch/spl.h> +#include <power/max77686_pmic.h> +#include <power/pmic.h> +#include <asm/arch/periph.h> +#include <asm/arch/pinmux.h>
static void exynos4_mipi_phy_control(unsigned int dev_index, unsigned int enable) @@ -95,3 +102,30 @@ void set_dp_phy_ctrl(unsigned int enable) if (cpu_is_exynos5()) exynos5_dp_phy_control(enable); }
+uint32_t power_read_reset_status(void) +{
struct exynos5_power *power =
(struct exynos5_power *)samsung_get_base_power();
return power->inform1;
+}
+void ps_hold_setup(void) +{
struct exynos5_power *power =
(struct exynos5_power *)samsung_get_base_power();
/* Set PS-Hold high */
setbits_le32(&power->ps_hold_control,
EXYNOS_PS_HOLD_CONTROL_DATA_HIGH);
+}
Suggest power_ps_hold_setup() so that the prefixes are consistent.
+void power_exit_wakeup(void) +{
struct exynos5_power *power =
(struct exynos5_power *)samsung_get_base_power();
typedef void (*resume_func)(void);
((resume_func)power->inform0)();
+} diff --git a/arch/arm/include/asm/arch-exynos/power.h b/arch/arm/include/asm/arch-exynos/power.h index d2fdb59..3e83f55 100644 --- a/arch/arm/include/asm/arch-exynos/power.h +++ b/arch/arm/include/asm/arch-exynos/power.h @@ -864,4 +864,9 @@ void set_dp_phy_ctrl(unsigned int enable);
#define EXYNOS_DP_PHY_ENABLE (1 << 0)
+#define EXYNOS_PS_HOLD_CONTROL_DATA_HIGH (1 << 8)
+uint32_t power_read_reset_status(void); +void ps_hold_setup(void); +void power_exit_wakeup(void);
Please can you add comments for these three functions
#endif
1.7.4.4

This patch adds required pmic voltage settings for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- board/samsung/smdk5250/smdk5250.c | 68 +++++++++++++++++++++++++++++++++++- include/power/max77686_pmic.h | 15 ++++++++ 2 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c index 73c3ec0..fe353a1 100644 --- a/board/samsung/smdk5250/smdk5250.c +++ b/board/samsung/smdk5250/smdk5250.c @@ -24,14 +24,17 @@ #include <fdtdec.h> #include <asm/io.h> #include <i2c.h> +#include <errno.h> #include <netdev.h> #include <spi.h> #include <asm/arch/cpu.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> #include <asm/arch/pinmux.h> +#include <asm/arch/power.h> #include <asm/arch/sromc.h> #include <power/pmic.h> +#include <power/max77686_pmic.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -60,10 +63,71 @@ int dram_init(void) #if defined(CONFIG_POWER) int power_init_board(void) { + struct pmic *p; + u32 val; + + ps_hold_setup(); + + i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); + if (pmic_init(I2C_PMIC)) return -1; - else - return 0; + + p = pmic_get("MAX77686_PMIC"); + if (!p) + return -ENODEV; + + if (pmic_probe(p)) + return -1; + + pmic_reg_read(p, MAX77686_REG_PMIC_32KHZ, &val); + val |= MAX77686_32KHCP_EN; + pmic_reg_write(p, MAX77686_REG_PMIC_32KHZ, val); + + pmic_reg_read(p, MAX77686_REG_PMIC_BBAT, &val); + val |= (MAX77686_BBCHOSTEN | MAX77686_BBCVS_3_5V); + pmic_reg_write(p, MAX77686_REG_PMIC_BBAT, val); + + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK1OUT, MAX77686_BUCK1OUT_1V); + pmic_reg_read(p, MAX77686_REG_PMIC_BUCK1CRTL, &val); + val |= MAX77686_BUCK1CTRL_EN; + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK1CRTL, val); + + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK2DVS1, + MAX77686_BUCK2DVS1_1_3V); + pmic_reg_read(p, MAX77686_REG_PMIC_BUCK2CTRL1, &val); + val |= MAX77686_BUCK2CTRL_ON; + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK2CTRL1, val); + + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK3DVS1, + MAX77686_BUCK3DVS1_1_0125V); + pmic_reg_read(p, MAX77686_REG_PMIC_BUCK3CTRL, &val); + val |= MAX77686_BUCK3CTRL_ON; + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK3CTRL, val); + + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK4DVS1, + MAX77686_BUCK4DVS1_1_2V); + pmic_reg_read(p, MAX77686_REG_PMIC_BUCK4CTRL1, &val); + val |= MAX77686_BUCK4CTRL_ON; + pmic_reg_write(p, MAX77686_REG_PMIC_BUCK4CTRL1, val); + + pmic_reg_read(p, MAX77686_REG_PMIC_LDO2CTRL1, &val); + val |= (MAX77686_LD02CTRL1_1_5V | EN_LDO); + pmic_reg_write(p, MAX77686_REG_PMIC_LDO2CTRL1, val); + + pmic_reg_read(p, MAX77686_REG_PMIC_LDO3CTRL1, &val); + val |= (MAX77686_LD03CTRL1_1_8V | EN_LDO); + pmic_reg_write(p, MAX77686_REG_PMIC_LDO3CTRL1, val); + + pmic_reg_read(p, MAX77686_REG_PMIC_LDO5CTRL1, &val); + val |= (MAX77686_LD05CTRL1_1_8V | EN_LDO); + pmic_reg_write(p, MAX77686_REG_PMIC_LDO5CTRL1, val); + + pmic_reg_read(p, MAX77686_REG_PMIC_LDO10CTRL1, &val); + val |= (MAX77686_LD10CTRL1_1_8V | EN_LDO); + pmic_reg_write(p, MAX77686_REG_PMIC_LDO10CTRL1, val); + + return 0; } #endif
diff --git a/include/power/max77686_pmic.h b/include/power/max77686_pmic.h index d949ace..fb3a8fb 100644 --- a/include/power/max77686_pmic.h +++ b/include/power/max77686_pmic.h @@ -155,4 +155,19 @@ enum { EN_LDO = (0x3 << 6), };
+#define MAX77686_BUCK1OUT_1V 0x5 +#define MAX77686_BUCK1CTRL_EN (3<<0) +#define MAX77686_BUCK2DVS1_1_3V 0x38 +#define MAX77686_BUCK2CTRL_ON (1<<4) +#define MAX77686_BUCK3DVS1_1_0125V 0x21 +#define MAX77686_BUCK3CTRL_ON (1<<4) +#define MAX77686_BUCK4DVS1_1_2V 0x30 +#define MAX77686_BUCK4CTRL_ON (1<<4) +#define MAX77686_LD02CTRL1_1_5V 0x1c +#define MAX77686_LD03CTRL1_1_8V 0x14 +#define MAX77686_LD05CTRL1_1_8V 0x14 +#define MAX77686_LD10CTRL1_1_8V 0x14 +#define MAX77686_32KHCP_EN (1<<1) +#define MAX77686_BBCHOSTEN (1<<0) +#define MAX77686_BBCVS_3_5V (3<<3) #endif /* __MAX77686_PMIC_H_ */

Hi Rajeshwari,
On Fri, Dec 28, 2012 at 4:08 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch adds required pmic voltage settings for SMDK5250.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
board/samsung/smdk5250/smdk5250.c | 68 +++++++++++++++++++++++++++++++++++- include/power/max77686_pmic.h | 15 ++++++++ 2 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c index 73c3ec0..fe353a1 100644 --- a/board/samsung/smdk5250/smdk5250.c +++ b/board/samsung/smdk5250/smdk5250.c @@ -24,14 +24,17 @@ #include <fdtdec.h> #include <asm/io.h> #include <i2c.h> +#include <errno.h> #include <netdev.h> #include <spi.h> #include <asm/arch/cpu.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> #include <asm/arch/pinmux.h> +#include <asm/arch/power.h> #include <asm/arch/sromc.h> #include <power/pmic.h> +#include <power/max77686_pmic.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -60,10 +63,71 @@ int dram_init(void) #if defined(CONFIG_POWER) int power_init_board(void) {
struct pmic *p;
u32 val;
ps_hold_setup();
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
if (pmic_init(I2C_PMIC)) return -1;
else
return 0;
p = pmic_get("MAX77686_PMIC");
if (!p)
return -ENODEV;
if (pmic_probe(p))
return -1;
pmic_reg_read(p, MAX77686_REG_PMIC_32KHZ, &val);
val |= MAX77686_32KHCP_EN;
pmic_reg_write(p, MAX77686_REG_PMIC_32KHZ, val);
Could we perhaps add a function like:
pmic_reg_update(struct pmic *p, int reg, uint mask, int val)
Also I think each of these calls needs error checking.
pmic_reg_read(p, MAX77686_REG_PMIC_BBAT, &val);
val |= (MAX77686_BBCHOSTEN | MAX77686_BBCVS_3_5V);
pmic_reg_write(p, MAX77686_REG_PMIC_BBAT, val);
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK1OUT, MAX77686_BUCK1OUT_1V);
pmic_reg_read(p, MAX77686_REG_PMIC_BUCK1CRTL, &val);
val |= MAX77686_BUCK1CTRL_EN;
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK1CRTL, val);
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK2DVS1,
MAX77686_BUCK2DVS1_1_3V);
pmic_reg_read(p, MAX77686_REG_PMIC_BUCK2CTRL1, &val);
val |= MAX77686_BUCK2CTRL_ON;
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK2CTRL1, val);
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK3DVS1,
MAX77686_BUCK3DVS1_1_0125V);
pmic_reg_read(p, MAX77686_REG_PMIC_BUCK3CTRL, &val);
val |= MAX77686_BUCK3CTRL_ON;
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK3CTRL, val);
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK4DVS1,
MAX77686_BUCK4DVS1_1_2V);
pmic_reg_read(p, MAX77686_REG_PMIC_BUCK4CTRL1, &val);
val |= MAX77686_BUCK4CTRL_ON;
pmic_reg_write(p, MAX77686_REG_PMIC_BUCK4CTRL1, val);
pmic_reg_read(p, MAX77686_REG_PMIC_LDO2CTRL1, &val);
val |= (MAX77686_LD02CTRL1_1_5V | EN_LDO);
pmic_reg_write(p, MAX77686_REG_PMIC_LDO2CTRL1, val);
pmic_reg_read(p, MAX77686_REG_PMIC_LDO3CTRL1, &val);
val |= (MAX77686_LD03CTRL1_1_8V | EN_LDO);
pmic_reg_write(p, MAX77686_REG_PMIC_LDO3CTRL1, val);
pmic_reg_read(p, MAX77686_REG_PMIC_LDO5CTRL1, &val);
val |= (MAX77686_LD05CTRL1_1_8V | EN_LDO);
pmic_reg_write(p, MAX77686_REG_PMIC_LDO5CTRL1, val);
pmic_reg_read(p, MAX77686_REG_PMIC_LDO10CTRL1, &val);
val |= (MAX77686_LD10CTRL1_1_8V | EN_LDO);
pmic_reg_write(p, MAX77686_REG_PMIC_LDO10CTRL1, val);
return 0;
} #endif
diff --git a/include/power/max77686_pmic.h b/include/power/max77686_pmic.h index d949ace..fb3a8fb 100644 --- a/include/power/max77686_pmic.h +++ b/include/power/max77686_pmic.h @@ -155,4 +155,19 @@ enum { EN_LDO = (0x3 << 6), };
+#define MAX77686_BUCK1OUT_1V 0x5 +#define MAX77686_BUCK1CTRL_EN (3<<0) +#define MAX77686_BUCK2DVS1_1_3V 0x38 +#define MAX77686_BUCK2CTRL_ON (1<<4) +#define MAX77686_BUCK3DVS1_1_0125V 0x21 +#define MAX77686_BUCK3CTRL_ON (1<<4) +#define MAX77686_BUCK4DVS1_1_2V 0x30 +#define MAX77686_BUCK4CTRL_ON (1<<4) +#define MAX77686_LD02CTRL1_1_5V 0x1c +#define MAX77686_LD03CTRL1_1_8V 0x14 +#define MAX77686_LD05CTRL1_1_8V 0x14 +#define MAX77686_LD10CTRL1_1_8V 0x14
Are these register values? If so I suggest adding a comment to that effect. Also spaces around <<
+#define MAX77686_32KHCP_EN (1<<1) +#define MAX77686_BBCHOSTEN (1<<0) +#define MAX77686_BBCVS_3_5V (3<<3)
#endif /* __MAX77686_PMIC_H_ */
1.7.4.4
Regards, Simon

IRAM stack pointer address to enable u-boot booting after conversion of lowlevel_init.S to lowlevel_init_c.c. Added CONFIG_CMD_BOOTZ to boot zImage.dtb kernel image.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- include/configs/exynos5250-dt.h | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index 59182f4..ae42e4b 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -199,9 +199,9 @@
#define CONFIG_DOS_PARTITION
-#define CONFIG_IRAM_STACK 0x02050000 - -#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR - 0x1000000) +#define CONFIG_IRAM_TOP 0x02050000 +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_IRAM_TOP - 0x800) +#define CONFIG_IRAM_STACK CONFIG_SYS_INIT_SP_ADDR
/* I2C */ #define CONFIG_SYS_I2C_INIT_BOARD @@ -297,4 +297,5 @@ #define CONFIG_SHA1 #define CONFIG_SHA256
+#define CONFIG_CMD_BOOTZ #endif /* __CONFIG_H */

Hi Rajeshwari,
On Fri, Dec 28, 2012 at 4:08 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
IRAM stack pointer address to enable u-boot booting after conversion of lowlevel_init.S to lowlevel_init_c.c. Added CONFIG_CMD_BOOTZ to boot zImage.dtb kernel image.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org
I believe the chip actually has a lot more than 80KB of SRAM. Should we set the top to the very top of SRAM?
include/configs/exynos5250-dt.h | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index 59182f4..ae42e4b 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -199,9 +199,9 @@
#define CONFIG_DOS_PARTITION
-#define CONFIG_IRAM_STACK 0x02050000
-#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR - 0x1000000) +#define CONFIG_IRAM_TOP 0x02050000 +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_IRAM_TOP - 0x800) +#define CONFIG_IRAM_STACK CONFIG_SYS_INIT_SP_ADDR
/* I2C */ #define CONFIG_SYS_I2C_INIT_BOARD @@ -297,4 +297,5 @@ #define CONFIG_SHA1 #define CONFIG_SHA256
+#define CONFIG_CMD_BOOTZ
#endif /* __CONFIG_H */
1.7.4.4
Regards, Simon
participants (4)
-
Kyungmin Park
-
Rajeshwari Birje
-
Rajeshwari Shinde
-
Simon Glass