1 From b4a826714297d304a42bfbe6622e66bbdebe0f61 Mon Sep 17 00:00:00 2001
2 From: Marek Vasut <marex@denx.de>
3 Date: Tue, 1 May 2012 11:09:44 +0000
4 Subject: [PATCH 46/56] i.MX28: Improve passing of data from SPL to U-Boot
6 Pass memory size from SPL via structure located in SRAM instead of SCRATCH
7 registers. This allows passing more data about boot from SPL to U-Boot, like the
8 boot mode pads configuration.
10 Signed-off-by: Marek Vasut <marex@denx.de>
11 Cc: Detlev Zundel <dzu@denx.de>
12 Cc: Fabio Estevam <fabio.estevam@freescale.com>
13 Cc: Stefano Babic <sbabic@denx.de>
14 Cc: Wolfgang Denk <wd@denx.de>
16 arch/arm/cpu/arm926ejs/mx28/mx28.c | 16 +++++-----------
17 arch/arm/cpu/arm926ejs/mx28/mx28_init.h | 1 +
18 arch/arm/cpu/arm926ejs/mx28/spl_boot.c | 7 +++++++
19 arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c | 10 +++-------
20 arch/arm/include/asm/arch-mx28/sys_proto.h | 4 ++++
21 5 files changed, 20 insertions(+), 18 deletions(-)
23 diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c
24 index dc0338d..54a68e1 100644
25 --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c
26 +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c
27 @@ -279,22 +279,16 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
29 int mx28_dram_init(void)
31 - struct mx28_digctl_regs *digctl_regs =
32 - (struct mx28_digctl_regs *)MXS_DIGCTL_BASE;
34 + struct mx28_spl_data *data = (struct mx28_spl_data *)
35 + ((CONFIG_SYS_TEXT_BASE - sizeof(struct mx28_spl_data)) & ~0xf);
37 - sz[0] = readl(&digctl_regs->hw_digctl_scratch0);
38 - sz[1] = readl(&digctl_regs->hw_digctl_scratch1);
40 - if (sz[0] != sz[1]) {
41 + if (data->mem_dram_size == 0) {
43 - "Error, the RAM size in HW_DIGCTRL_SCRATCH0 and\n"
44 - "HW_DIGCTRL_SCRATCH1 is not the same. Please\n"
45 - "verify these two registers contain valid RAM size!\n");
46 + "Error, the RAM size passed up from SPL is 0!\n");
50 - gd->ram_size = sz[0];
51 + gd->ram_size = data->mem_dram_size;
55 diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28_init.h b/arch/arm/cpu/arm926ejs/mx28/mx28_init.h
56 index 98d3631..8eac958 100644
57 --- a/arch/arm/cpu/arm926ejs/mx28/mx28_init.h
58 +++ b/arch/arm/cpu/arm926ejs/mx28/mx28_init.h
59 @@ -37,5 +37,6 @@ static inline void mx28_power_wait_pswitch(void) { }
62 void mx28_mem_init(void);
63 +uint32_t mx28_mem_get_size(void);
65 #endif /* __M28_INIT_H__ */
66 diff --git a/arch/arm/cpu/arm926ejs/mx28/spl_boot.c b/arch/arm/cpu/arm926ejs/mx28/spl_boot.c
67 index dfb8309..37e1eb7 100644
68 --- a/arch/arm/cpu/arm926ejs/mx28/spl_boot.c
69 +++ b/arch/arm/cpu/arm926ejs/mx28/spl_boot.c
72 #include <asm/arch/iomux-mx28.h>
73 #include <asm/arch/imx-regs.h>
74 +#include <asm/arch/sys_proto.h>
76 #include "mx28_init.h"
78 @@ -49,9 +50,15 @@ void early_delay(int delay)
79 void mx28_common_spl_init(const iomux_cfg_t *iomux_setup,
80 const unsigned int iomux_size)
82 + struct mx28_spl_data *data = (struct mx28_spl_data *)
83 + ((CONFIG_SYS_TEXT_BASE - sizeof(struct mx28_spl_data)) & ~0xf);
85 mxs_iomux_setup_multiple_pads(iomux_setup, iomux_size);
89 + data->mem_dram_size = mx28_mem_get_size();
91 mx28_power_wait_pswitch();
94 diff --git a/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c b/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c
95 index 69c865e..9fa5d29 100644
96 --- a/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c
97 +++ b/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c
98 @@ -175,10 +175,8 @@ void mx28_mem_setup_vddd(void)
99 &power_regs->hw_power_vdddctrl);
102 -void mx28_mem_get_size(void)
103 +uint32_t mx28_mem_get_size(void)
105 - struct mx28_digctl_regs *digctl_regs =
106 - (struct mx28_digctl_regs *)MXS_DIGCTL_BASE;
108 uint32_t *vt = (uint32_t *)0x20;
109 /* The following is "subs pc, r14, #4", used as return from DABT. */
110 @@ -189,11 +187,11 @@ void mx28_mem_get_size(void)
111 vt[4] = data_abort_memdetect_handler;
113 sz = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
114 - writel(sz, &digctl_regs->hw_digctl_scratch0);
115 - writel(sz, &digctl_regs->hw_digctl_scratch1);
117 /* Restore the old DABT handler. */
123 void mx28_mem_init(void)
124 @@ -241,6 +239,4 @@ void mx28_mem_init(void)
127 mx28_mem_setup_cpu_and_hbus();
129 - mx28_mem_get_size();
131 diff --git a/arch/arm/include/asm/arch-mx28/sys_proto.h b/arch/arm/include/asm/arch-mx28/sys_proto.h
132 index 15d8de3..04f2e4d 100644
133 --- a/arch/arm/include/asm/arch-mx28/sys_proto.h
134 +++ b/arch/arm/include/asm/arch-mx28/sys_proto.h
135 @@ -39,6 +39,10 @@ void mx28_common_spl_init(const iomux_cfg_t *iomux_setup,
136 const unsigned int iomux_size);
139 +struct mx28_spl_data {
140 + uint32_t mem_dram_size;
143 int mx28_dram_init(void);
145 #endif /* __MX28_H__ */