aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/offb.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-10-26 01:38:10 -0400
committerPaul Mackerras <paulus@samba.org>2006-10-31 22:52:48 -0500
commit441cbd8dace80545db2ac43175ac1c097d96f75c (patch)
treefd56c377409091420b9fb159730779bb6d68b3bb /drivers/video/offb.c
parentd5b9b787b5e1618dfe82a2c2a6972374e85b02db (diff)
[POWERPC] Fix various offb issues
This patch fixes a few issues in offb: - A test was inverted causing the palette hack to never work (no device node was passed down to the init function) - Some cards seem to have their assigned-addresses property in a random order, thus we need to try using of_get_pci_address() first, which will fail if it's not a PCI device, and fallback to of_get_address() in that case. of_get_pci_address() properly parsees assigned-addresses to test the BAR number and thus will get it right whatever the order is. - Some cards (like GXT4500) provide a linebytes of 0xffffffff in the device-tree which does no good. This patch handles that by using the screen width when that happens. (Also fixes btext.c while at it). - Add detection of the GXT4500 in addition to the GXT2000 for the palette hacks (we use the same hack, palette is linear in register space at offset 0x6000). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/video/offb.c')
-rw-r--r--drivers/video/offb.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index bad0e98fb3b6..9a40bbecf76b 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -157,7 +157,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); 157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
158 break; 158 break;
159 case cmap_gxt2000: 159 case cmap_gxt2000:
160 out_le32((unsigned __iomem *) par->cmap_adr + regno, 160 out_le32(((unsigned __iomem *) par->cmap_adr) + regno,
161 (red << 16 | green << 8 | blue)); 161 (red << 16 | green << 8 | blue));
162 break; 162 break;
163 } 163 }
@@ -213,7 +213,7 @@ static int offb_blank(int blank, struct fb_info *info)
213 out_le32(par->cmap_adr + 0xb4, 0); 213 out_le32(par->cmap_adr + 0xb4, 0);
214 break; 214 break;
215 case cmap_gxt2000: 215 case cmap_gxt2000:
216 out_le32((unsigned __iomem *) par->cmap_adr + i, 216 out_le32(((unsigned __iomem *) par->cmap_adr) + i,
217 0); 217 0);
218 break; 218 break;
219 } 219 }
@@ -226,13 +226,23 @@ static int offb_blank(int blank, struct fb_info *info)
226static void __iomem *offb_map_reg(struct device_node *np, int index, 226static void __iomem *offb_map_reg(struct device_node *np, int index,
227 unsigned long offset, unsigned long size) 227 unsigned long offset, unsigned long size)
228{ 228{
229 struct resource r; 229 const u32 *addrp;
230 230 u64 asize, taddr;
231 if (of_address_to_resource(np, index, &r)) 231 unsigned int flags;
232 return 0; 232
233 if ((r.start + offset + size) > r.end) 233 addrp = of_get_pci_address(np, index, &asize, &flags);
234 return 0; 234 if (addrp == NULL)
235 return ioremap(r.start + offset, size); 235 addrp = of_get_address(np, index, &asize, &flags);
236 if (addrp == NULL)
237 return NULL;
238 if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
239 return NULL;
240 if ((offset + size) > asize)
241 return NULL;
242 taddr = of_translate_address(np, addrp);
243 if (taddr == OF_BAD_ADDR)
244 return NULL;
245 return ioremap(taddr + offset, size);
236} 246}
237 247
238static void __init offb_init_fb(const char *name, const char *full_name, 248static void __init offb_init_fb(const char *name, const char *full_name,
@@ -289,7 +299,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
289 299
290 par->cmap_type = cmap_unknown; 300 par->cmap_type = cmap_unknown;
291 if (depth == 8) { 301 if (depth == 8) {
292 /* Palette hacks disabled for now */
293 if (dp && !strncmp(name, "ATY,Rage128", 11)) { 302 if (dp && !strncmp(name, "ATY,Rage128", 11)) {
294 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); 303 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
295 if (par->cmap_adr) 304 if (par->cmap_adr)
@@ -313,7 +322,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
313 ioremap(base + 0x7ff000, 0x1000) + 0xcc0; 322 ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
314 par->cmap_data = par->cmap_adr + 1; 323 par->cmap_data = par->cmap_adr + 1;
315 par->cmap_type = cmap_m64; 324 par->cmap_type = cmap_m64;
316 } else if (dp && device_is_compatible(dp, "pci1014,b7")) { 325 } else if (dp && (device_is_compatible(dp, "pci1014,b7") ||
326 device_is_compatible(dp, "pci1014,21c"))) {
317 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); 327 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
318 if (par->cmap_adr) 328 if (par->cmap_adr)
319 par->cmap_type = cmap_gxt2000; 329 par->cmap_type = cmap_gxt2000;
@@ -433,7 +443,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
433 pp = get_property(dp, "linux,bootx-linebytes", &len); 443 pp = get_property(dp, "linux,bootx-linebytes", &len);
434 if (pp == NULL) 444 if (pp == NULL)
435 pp = get_property(dp, "linebytes", &len); 445 pp = get_property(dp, "linebytes", &len);
436 if (pp && len == sizeof(u32)) 446 if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
437 pitch = *pp; 447 pitch = *pp;
438 else 448 else
439 pitch = width * ((depth + 7) / 8); 449 pitch = width * ((depth + 7) / 8);
@@ -496,7 +506,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
496 offb_init_fb(no_real_node ? "bootx" : dp->name, 506 offb_init_fb(no_real_node ? "bootx" : dp->name,
497 no_real_node ? "display" : dp->full_name, 507 no_real_node ? "display" : dp->full_name,
498 width, height, depth, pitch, address, 508 width, height, depth, pitch, address,
499 no_real_node ? dp : NULL); 509 no_real_node ? NULL : dp);
500 } 510 }
501} 511}
502 512