5757#include <mach/timex.h>
5858#include <mach/sys_config.h>
5959
60- /* Enable or disable various subsystems according to what drivers we're
61- * building with.
62- */
63-
64- #if defined CONFIG_FB || defined CONFIG_FB_MODULE
65- /* The FB block is used by:
66- *
67- * - the sun4i framebuffer driver, drivers/video/sun4i/disp.
68- *
69- * fb_start, fb_size are used in a vast number of other places but for
70- * for platform-specific drivers, so we don't have to worry about them.
71- *
72- * The block will only be allocated if the disp_init/disp_init_enabled
73- * script key is set.
74- */
75- #define USE_FB
76- #endif
77-
78- #if defined CONFIG_SUN4I_G2D || defined CONFIG_SUN4I_G2D_MODULE
79- /* The G2D block is used by:
80- *
81- * - the G2D engine, drivers/char/sun4i_g2d
82- *
83- * The block will only be allocated if the g2d_para/g2d_used
84- * script key is set.
85- */
86- #define USE_G2D
87- #endif
88-
89- #if defined CONFIG_VIDEO_DECODER_SUN4I || defined CONFIG_VIDEO_DECODER_SUN4I_MODULE
90- /* The VE block is used by:
91- *
92- * - the Cedar video engine, drivers/media/video/sun4i
93- *
94- * ve_start, ve_size are also used by the contiguous-DMA module in
95- * drivers/media/video/videobuf-dma-contig.c, but that's SH-specific
96- * so we don't have to worry about it here.
97- */
98- #define USE_VE
99- #endif
100-
10160/**
10261 * Machine Implementations
10362 *
@@ -170,43 +129,62 @@ static void __init sw_core_fixup(struct machine_desc *desc,
170129 pr_info ("Total Detected Memory: %uMB with %d banks\n" , size , mi -> nr_banks );
171130}
172131
173- #if defined USE_FB
132+ /* Only reserve certain important memory blocks if there are actually
133+ * drivers which use them.
134+ */
135+
136+ #if defined CONFIG_FB || defined CONFIG_FB_MODULE
137+ /* The FB block is used by:
138+ *
139+ * - the sun4i framebuffer driver, drivers/video/sun4i/disp.
140+ *
141+ * fb_start, fb_size are used in a vast number of other places but for
142+ * for platform-specific drivers, so we don't have to worry about them.
143+ *
144+ * The block will only be allocated if the disp_init/disp_init_enabled
145+ * script key is set.
146+ */
147+
174148unsigned long fb_start = (PLAT_PHYS_OFFSET + SZ_512M - SZ_64M - SZ_32M );
175149unsigned long fb_size = SZ_32M ;
176150EXPORT_SYMBOL (fb_start );
177151EXPORT_SYMBOL (fb_size );
152+
153+ static void __init reserve_fb (void )
154+ {
155+ char * script_base = (char * )(PAGE_OFFSET + 0x3000000 );
156+
157+ if (sw_cfg_get_int (script_base , "disp_init" , "disp_init_enable" ))
158+ {
159+ memblock_reserve (fb_start , fb_size );
160+ pr_info ("\tLCD: 0x%08x, 0x%08x\n" , (unsigned int )fb_start , (unsigned int )fb_size );
161+ }
162+ else
163+ fb_start = fb_size = 0 ;
164+ }
165+
166+ #else
167+ static void __init reserve_fb (void ) {}
178168#endif
179169
180- #if defined USE_G2D
170+ #if defined CONFIG_SUN4I_G2D || defined CONFIG_SUN4I_G2D_MODULE
171+ /* The G2D block is used by:
172+ *
173+ * - the G2D engine, drivers/char/sun4i_g2d
174+ *
175+ * The block will only be allocated if the g2d_para/g2d_used
176+ * script key is set.
177+ */
178+
181179unsigned long g2d_start = (PLAT_PHYS_OFFSET + SZ_512M - SZ_128M );
182180unsigned long g2d_size = SZ_1M * 16 ;
183181EXPORT_SYMBOL (g2d_start );
184182EXPORT_SYMBOL (g2d_size );
185- #endif
186183
187- #if defined USE_VE
188- unsigned long ve_start = (PLAT_PHYS_OFFSET + SZ_64M );
189- unsigned long ve_size = (SZ_64M + SZ_16M );
190- EXPORT_SYMBOL (ve_start );
191- EXPORT_SYMBOL (ve_size );
192- #endif
193-
194- static void __init sw_core_reserve (void )
184+ static void __init reserve_g2d (void )
195185{
196- #if (defined USE_FB ) || (defined USE_G2D ) || (defined USE_VE )
197186 char * script_base = (char * )(PAGE_OFFSET + 0x3000000 );
198- #endif
199-
200- memblock_reserve (SYS_CONFIG_MEMBASE , SYS_CONFIG_MEMSIZE );
201-
202- #if defined USE_FB
203- if (sw_cfg_get_int (script_base , "disp_init" , "disp_init_enable" ))
204- memblock_reserve (fb_start , fb_size );
205- else
206- fb_start = fb_size = 0 ;
207- #endif
208187
209- #if defined USE_G2D
210188 if (sw_cfg_get_int (script_base , "g2d_para" , "g2d_used" ))
211189 {
212190 g2d_size = sw_cfg_get_int (script_base , "g2d_para" , "g2d_size" );
@@ -216,34 +194,63 @@ static void __init sw_core_reserve(void)
216194 g2d_start = SW_G2D_MEM_BASE ;
217195 g2d_size = g2d_size ;
218196 memblock_reserve (g2d_start , g2d_size );
197+
198+ pr_info ("\tG2D: 0x%08x, 0x%08x\n" , (unsigned int )g2d_start , (unsigned int )g2d_size );
219199 }
220200 else
221201 g2d_start = g2d_size = 0 ;
202+ }
203+
204+ #else
205+ static void __init reserve_g2d (void ) {}
222206#endif
223207
224- #if defined USE_VE
208+ #if defined CONFIG_VIDEO_DECODER_SUN4I || defined CONFIG_VIDEO_DECODER_SUN4I_MODULE
209+ /* The VE block is used by:
210+ *
211+ * - the Cedar video engine, drivers/media/video/sun4i
212+ *
213+ * ve_start, ve_size are also used by the contiguous-DMA module in
214+ * drivers/media/video/videobuf-dma-contig.c, but that's SH-specific
215+ * so we don't have to worry about it here.
216+ */
217+
218+ unsigned long ve_start = (PLAT_PHYS_OFFSET + SZ_64M );
219+ unsigned long ve_size = (SZ_64M + SZ_16M );
220+ EXPORT_SYMBOL (ve_start );
221+ EXPORT_SYMBOL (ve_size );
222+
223+ static void __init reserve_ve (void )
224+ {
225225 /* The users of the VE block aren't enabled via script flags, so if their
226226 * driver gets compiled in we have to unconditionally reserve memory for
227227 * them.
228228 */
229229 memblock_reserve (ve_start , SZ_64M );
230230 memblock_reserve (ve_start + SZ_64M , SZ_16M );
231+
232+ pr_info ("\tVE : 0x%08x, 0x%08x\n" , (unsigned int )ve_start , (unsigned int )ve_size );
233+ }
234+
235+ #else
236+ static void __init reserve_ve (void ) {}
231237#endif
232238
239+ static void reserve_sys (void )
240+ {
241+ memblock_reserve (SYS_CONFIG_MEMBASE , SYS_CONFIG_MEMSIZE );
242+ pr_info ("\tSYS: 0x%08x, 0x%08x\n" ,
243+ (unsigned int )SYS_CONFIG_MEMBASE ,
244+ (unsigned int )SYS_CONFIG_MEMSIZE );
245+ }
246+
247+ static void __init sw_core_reserve (void )
248+ {
233249 pr_info ("Memory Reserved(in bytes):\n" );
234- #if defined USE_FB
235- if (fb_start )
236- pr_info ("\tLCD: 0x%08x, 0x%08x\n" , (unsigned int )fb_start , (unsigned int )fb_size );
237- #endif
238- pr_info ("\tSYS: 0x%08x, 0x%08x\n" , (unsigned int )SYS_CONFIG_MEMBASE , (unsigned int )SYS_CONFIG_MEMSIZE );
239- #if defined USE_G2D
240- if (g2d_start )
241- pr_info ("\tG2D: 0x%08x, 0x%08x\n" , (unsigned int )g2d_start , (unsigned int )g2d_size );
242- #endif
243- #if defined USE_VE
244- if (ve_start )
245- pr_info ("\tVE : 0x%08x, 0x%08x\n" , (unsigned int )ve_start , (unsigned int )ve_size );
246- #endif
250+ reserve_sys ();
251+ reserve_fb ();
252+ reserve_g2d ();
253+ reserve_ve ();
247254}
248255
249256void sw_irq_ack (struct irq_data * irqd )
0 commit comments