@@ -129,54 +129,128 @@ static void __init sw_core_fixup(struct machine_desc *desc,
129129 pr_info ("Total Detected Memory: %uMB with %d banks\n" , size , mi -> nr_banks );
130130}
131131
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+
132148unsigned long fb_start = (PLAT_PHYS_OFFSET + SZ_512M - SZ_64M - SZ_32M );
133149unsigned long fb_size = SZ_32M ;
134150EXPORT_SYMBOL (fb_start );
135151EXPORT_SYMBOL (fb_size );
136152
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 ) {}
168+ #endif
169+
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+
137179unsigned long g2d_start = (PLAT_PHYS_OFFSET + SZ_512M - SZ_128M );
138180unsigned long g2d_size = SZ_1M * 16 ;
139181EXPORT_SYMBOL (g2d_start );
140182EXPORT_SYMBOL (g2d_size );
141183
184+ static void __init reserve_g2d (void )
185+ {
186+ char * script_base = (char * )(PAGE_OFFSET + 0x3000000 );
187+
188+ if (sw_cfg_get_int (script_base , "g2d_para" , "g2d_used" ))
189+ {
190+ g2d_size = sw_cfg_get_int (script_base , "g2d_para" , "g2d_size" );
191+ if ((g2d_size < 0 ) || (g2d_size > SW_G2D_MEM_MAX ))
192+ g2d_size = SW_G2D_MEM_MAX ;
193+
194+ g2d_start = SW_G2D_MEM_BASE ;
195+ g2d_size = g2d_size ;
196+ memblock_reserve (g2d_start , g2d_size );
197+
198+ pr_info ("\tG2D: 0x%08x, 0x%08x\n" , (unsigned int )g2d_start , (unsigned int )g2d_size );
199+ }
200+ else
201+ g2d_start = g2d_size = 0 ;
202+ }
203+
204+ #else
205+ static void __init reserve_g2d (void ) {}
206+ #endif
207+
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+
142218unsigned long ve_start = (PLAT_PHYS_OFFSET + SZ_64M );
143219unsigned long ve_size = (SZ_64M + SZ_16M );
144220EXPORT_SYMBOL (ve_start );
145221EXPORT_SYMBOL (ve_size );
146222
147- static void __init sw_core_reserve (void )
223+ static void __init reserve_ve (void )
148224{
149- memblock_reserve (SYS_CONFIG_MEMBASE , SYS_CONFIG_MEMSIZE );
150- memblock_reserve (fb_start , fb_size );
225+ /* The users of the VE block aren't enabled via script flags, so if their
226+ * driver gets compiled in we have to unconditionally reserve memory for
227+ * them.
228+ */
151229 memblock_reserve (ve_start , SZ_64M );
152230 memblock_reserve (ve_start + SZ_64M , SZ_16M );
153231
154- #if 0
155- int g2d_used = 0 ;
156- char * script_base = (char * )(PAGE_OFFSET + 0x3000000 );
232+ pr_info ("\tVE : 0x%08x, 0x%08x\n" , (unsigned int )ve_start , (unsigned int )ve_size );
233+ }
157234
158- g2d_used = sw_cfg_get_int (script_base , "g2d_para" , "g2d_used" );
235+ #else
236+ static void __init reserve_ve (void ) {}
237+ #endif
159238
160- memblock_reserve (fb_start , fb_size );
239+ static void reserve_sys (void )
240+ {
161241 memblock_reserve (SYS_CONFIG_MEMBASE , SYS_CONFIG_MEMSIZE );
162- memblock_reserve (ve_start , ve_start );
163-
164- if (g2d_used ) {
165- g2d_size = sw_cfg_get_int (script_base , "g2d_para" , "g2d_size" );
166- if (g2d_size < 0 || g2d_size > SW_G2D_MEM_MAX ) {
167- g2d_size = SW_G2D_MEM_MAX ;
168- }
169- g2d_start = SW_G2D_MEM_BASE ;
170- g2d_size = g2d_size ;
171- memblock_reserve (g2d_start , g2d_size );
172- }
242+ pr_info ("\tSYS: 0x%08x, 0x%08x\n" ,
243+ (unsigned int )SYS_CONFIG_MEMBASE ,
244+ (unsigned int )SYS_CONFIG_MEMSIZE );
245+ }
173246
174- #endif
247+ static void __init sw_core_reserve (void )
248+ {
175249 pr_info ("Memory Reserved(in bytes):\n" );
176- pr_info ( "\tLCD: 0x%08x, 0x%08x\n" , ( unsigned int ) fb_start , ( unsigned int ) fb_size );
177- pr_info ( "\tSYS: 0x%08x, 0x%08x\n" , ( unsigned int ) SYS_CONFIG_MEMBASE , ( unsigned int ) SYS_CONFIG_MEMSIZE );
178- pr_info ( "\tG2D: 0x%08x, 0x%08x\n" , ( unsigned int ) g2d_start , ( unsigned int ) g2d_size );
179- pr_info ( "\tVE : 0x%08x, 0x%08x\n" , ( unsigned int ) ve_start , ( unsigned int ) ve_size );
250+ reserve_sys ( );
251+ reserve_fb ( );
252+ reserve_g2d ( );
253+ reserve_ve ( );
180254}
181255
182256void sw_irq_ack (struct irq_data * irqd )
0 commit comments