aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/offb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/offb.c')
-rw-r--r--drivers/video/offb.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 2c856838694e..00d87f5bb7be 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -26,6 +26,7 @@
26#include <linux/fb.h> 26#include <linux/fb.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/pci.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/prom.h> 31#include <asm/prom.h>
31 32
@@ -325,8 +326,8 @@ static void __init offb_init_nodriver(struct device_node *dp)
325 int *pp, i; 326 int *pp, i;
326 unsigned int len; 327 unsigned int len;
327 int width = 640, height = 480, depth = 8, pitch; 328 int width = 640, height = 480, depth = 8, pitch;
328 unsigned *up; 329 unsigned int rsize, *up;
329 unsigned long address; 330 unsigned long address = 0;
330 331
331 if ((pp = (int *) get_property(dp, "depth", &len)) != NULL 332 if ((pp = (int *) get_property(dp, "depth", &len)) != NULL
332 && len == sizeof(int)) 333 && len == sizeof(int))
@@ -344,10 +345,40 @@ static void __init offb_init_nodriver(struct device_node *dp)
344 pitch = 0x1000; 345 pitch = 0x1000;
345 } else 346 } else
346 pitch = width; 347 pitch = width;
347 if ((up = (unsigned *) get_property(dp, "address", &len)) != NULL 348
348 && len == sizeof(unsigned)) 349 rsize = (unsigned long)pitch * (unsigned long)height *
350 (unsigned long)(depth / 8);
351
352 /* Try to match device to a PCI device in order to get a properly
353 * translated address rather then trying to decode the open firmware
354 * stuff in various incorrect ways
355 */
356#ifdef CONFIG_PCI
357 /* First try to locate the PCI device if any */
358 {
359 struct pci_dev *pdev = NULL;
360
361 for_each_pci_dev(pdev) {
362 if (dp == pci_device_to_OF_node(pdev))
363 break;
364 }
365 if (pdev) {
366 for (i = 0; i < 6 && address == 0; i++) {
367 if ((pci_resource_flags(pdev, i) &
368 IORESOURCE_MEM) &&
369 (pci_resource_len(pdev, i) >= rsize))
370 address = pci_resource_start(pdev, i);
371 }
372 pci_dev_put(pdev);
373 }
374 }
375#endif /* CONFIG_PCI */
376
377 if (address == 0 &&
378 (up = (unsigned *) get_property(dp, "address", &len)) != NULL &&
379 len == sizeof(unsigned))
349 address = (u_long) * up; 380 address = (u_long) * up;
350 else { 381 if (address == 0) {
351 for (i = 0; i < dp->n_addrs; ++i) 382 for (i = 0; i < dp->n_addrs; ++i)
352 if (dp->addrs[i].size >= 383 if (dp->addrs[i].size >=
353 pitch * height * depth / 8) 384 pitch * height * depth / 8)