aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/plat-omap/fb.c61
1 files changed, 44 insertions, 17 deletions
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index d3eea4f47533..97db493904fa 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -171,49 +171,76 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg,
171 return 0; 171 return 0;
172} 172}
173 173
174static int valid_sdram(unsigned long addr, unsigned long size)
175{
176 struct bootmem_data *bdata = NODE_DATA(0)->bdata;
177 unsigned long sdram_start, sdram_end;
178
179 sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
180 sdram_end = bdata->node_low_pfn << PAGE_SHIFT;
181
182 return addr >= sdram_start && sdram_end - addr >= size;
183}
184
185static int reserve_sdram(unsigned long addr, unsigned long size)
186{
187 return reserve_bootmem(addr, size, BOOTMEM_EXCLUSIVE);
188}
189
174/* 190/*
175 * Called from map_io. We need to call to this early enough so that we 191 * Called from map_io. We need to call to this early enough so that we
176 * can reserve the fixed SDRAM regions before VM could get hold of them. 192 * can reserve the fixed SDRAM regions before VM could get hold of them.
177 */ 193 */
178void __init omapfb_reserve_sdram(void) 194void __init omapfb_reserve_sdram(void)
179{ 195{
180 struct bootmem_data *bdata; 196 unsigned long reserved = 0;
181 unsigned long sdram_start, sdram_size; 197 int i;
182 unsigned long reserved;
183 int i;
184 198
185 if (config_invalid) 199 if (config_invalid)
186 return; 200 return;
187 201
188 bdata = NODE_DATA(0)->bdata;
189 sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
190 sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start;
191 reserved = 0;
192 for (i = 0; ; i++) { 202 for (i = 0; ; i++) {
193 struct omapfb_mem_region rg; 203 struct omapfb_mem_region rg;
194 204
195 if (get_fbmem_region(i, &rg) < 0) 205 if (get_fbmem_region(i, &rg) < 0)
196 break; 206 break;
207
197 if (i == OMAPFB_PLANE_NUM) { 208 if (i == OMAPFB_PLANE_NUM) {
198 printk(KERN_ERR 209 pr_err("Extraneous FB mem configuration entries\n");
199 "Extraneous FB mem configuration entries\n");
200 config_invalid = 1; 210 config_invalid = 1;
201 return; 211 return;
202 } 212 }
213
203 /* Check if it's our memory type. */ 214 /* Check if it's our memory type. */
204 if (set_fbmem_region_type(&rg, OMAPFB_MEMTYPE_SDRAM, 215 if (rg.type != OMAPFB_MEMTYPE_SDRAM)
205 sdram_start, sdram_size) < 0 ||
206 (rg.type != OMAPFB_MEMTYPE_SDRAM))
207 continue; 216 continue;
208 BUG_ON(omapfb_config.mem_desc.region[i].size); 217
209 if (check_fbmem_region(i, &rg, sdram_start, sdram_size) < 0) { 218 /* Check if the region falls within SDRAM */
219 if (rg.paddr && !valid_sdram(rg.paddr, rg.size))
220 continue;
221
222 if (rg.size == 0) {
223 pr_err("Zero size for FB region %d\n", i);
210 config_invalid = 1; 224 config_invalid = 1;
211 return; 225 return;
212 } 226 }
227
213 if (rg.paddr) { 228 if (rg.paddr) {
214 reserve_bootmem(rg.paddr, rg.size, BOOTMEM_DEFAULT); 229 if (reserve_sdram(rg.paddr, rg.size)) {
230 pr_err("Trying to use reserved memory for FB region %d\n",
231 i);
232 config_invalid = 1;
233 return;
234 }
215 reserved += rg.size; 235 reserved += rg.size;
216 } 236 }
237
238 if (omapfb_config.mem_desc.region[i].size) {
239 pr_err("FB region %d already set\n", i);
240 config_invalid = 1;
241 return;
242 }
243
217 omapfb_config.mem_desc.region[i] = rg; 244 omapfb_config.mem_desc.region[i] = rg;
218 configured_regions++; 245 configured_regions++;
219 } 246 }