]> code.ossystems Code Review - meta-freescale.git/blob
e84bd249cf00a46d59860034b9a45c6d7b99e6ee
[meta-freescale.git] /
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
5
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.
9
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>
15 ---
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(-)
22
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)
28  
29  int mx28_dram_init(void)
30  {
31 -       struct mx28_digctl_regs *digctl_regs =
32 -               (struct mx28_digctl_regs *)MXS_DIGCTL_BASE;
33 -       uint32_t sz[2];
34 +       struct mx28_spl_data *data = (struct mx28_spl_data *)
35 +               ((CONFIG_SYS_TEXT_BASE - sizeof(struct mx28_spl_data)) & ~0xf);
36  
37 -       sz[0] = readl(&digctl_regs->hw_digctl_scratch0);
38 -       sz[1] = readl(&digctl_regs->hw_digctl_scratch1);
39 -
40 -       if (sz[0] != sz[1]) {
41 +       if (data->mem_dram_size == 0) {
42                 printf("MX28:\n"
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");
47                 hang();
48         }
49  
50 -       gd->ram_size = sz[0];
51 +       gd->ram_size = data->mem_dram_size;
52         return 0;
53  }
54  
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) { }
60  #endif
61  
62  void mx28_mem_init(void);
63 +uint32_t mx28_mem_get_size(void);
64  
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
70 @@ -28,6 +28,7 @@
71  #include <asm/io.h>
72  #include <asm/arch/iomux-mx28.h>
73  #include <asm/arch/imx-regs.h>
74 +#include <asm/arch/sys_proto.h>
75  
76  #include "mx28_init.h"
77  
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)
81  {
82 +       struct mx28_spl_data *data = (struct mx28_spl_data *)
83 +               ((CONFIG_SYS_TEXT_BASE - sizeof(struct mx28_spl_data)) & ~0xf);
84 +
85         mxs_iomux_setup_multiple_pads(iomux_setup, iomux_size);
86         mx28_power_init();
87 +
88         mx28_mem_init();
89 +       data->mem_dram_size = mx28_mem_get_size();
90 +
91         mx28_power_wait_pswitch();
92  }
93  
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);
100  }
101  
102 -void mx28_mem_get_size(void)
103 +uint32_t mx28_mem_get_size(void)
104  {
105 -       struct mx28_digctl_regs *digctl_regs =
106 -               (struct mx28_digctl_regs *)MXS_DIGCTL_BASE;
107         uint32_t sz, da;
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;
112  
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);
116  
117         /* Restore the old DABT handler. */
118         vt[4] = da;
119 +
120 +       return sz;
121  }
122  
123  void mx28_mem_init(void)
124 @@ -241,6 +239,4 @@ void mx28_mem_init(void)
125         early_delay(10000);
126  
127         mx28_mem_setup_cpu_and_hbus();
128 -
129 -       mx28_mem_get_size();
130  }
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);
137  #endif
138  
139 +struct mx28_spl_data {
140 +       uint32_t        mem_dram_size;
141 +};
142 +
143  int mx28_dram_init(void);
144  
145  #endif /* __MX28_H__ */
146 -- 
147 1.7.10
148