Commit 441cbd8d authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Paul Mackerras

[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: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent d5b9b787
...@@ -182,7 +182,7 @@ int btext_initialize(struct device_node *np) ...@@ -182,7 +182,7 @@ int btext_initialize(struct device_node *np)
prop = get_property(np, "linux,bootx-linebytes", NULL); prop = get_property(np, "linux,bootx-linebytes", NULL);
if (prop == NULL) if (prop == NULL)
prop = get_property(np, "linebytes", NULL); prop = get_property(np, "linebytes", NULL);
if (prop) if (prop && *prop != 0xffffffffu)
pitch = *prop; pitch = *prop;
if (pitch == 1) if (pitch == 1)
pitch = 0x1000; pitch = 0x1000;
......
...@@ -157,7 +157,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -157,7 +157,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
break; break;
case cmap_gxt2000: case cmap_gxt2000:
out_le32((unsigned __iomem *) par->cmap_adr + regno, out_le32(((unsigned __iomem *) par->cmap_adr) + regno,
(red << 16 | green << 8 | blue)); (red << 16 | green << 8 | blue));
break; break;
} }
...@@ -213,7 +213,7 @@ static int offb_blank(int blank, struct fb_info *info) ...@@ -213,7 +213,7 @@ static int offb_blank(int blank, struct fb_info *info)
out_le32(par->cmap_adr + 0xb4, 0); out_le32(par->cmap_adr + 0xb4, 0);
break; break;
case cmap_gxt2000: case cmap_gxt2000:
out_le32((unsigned __iomem *) par->cmap_adr + i, out_le32(((unsigned __iomem *) par->cmap_adr) + i,
0); 0);
break; break;
} }
...@@ -226,13 +226,23 @@ static int offb_blank(int blank, struct fb_info *info) ...@@ -226,13 +226,23 @@ static int offb_blank(int blank, struct fb_info *info)
static void __iomem *offb_map_reg(struct device_node *np, int index, static void __iomem *offb_map_reg(struct device_node *np, int index,
unsigned long offset, unsigned long size) unsigned long offset, unsigned long size)
{ {
struct resource r; const u32 *addrp;
u64 asize, taddr;
if (of_address_to_resource(np, index, &r)) unsigned int flags;
return 0;
if ((r.start + offset + size) > r.end) addrp = of_get_pci_address(np, index, &asize, &flags);
return 0; if (addrp == NULL)
return ioremap(r.start + offset, size); addrp = of_get_address(np, index, &asize, &flags);
if (addrp == NULL)
return NULL;
if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
return NULL;
if ((offset + size) > asize)
return NULL;
taddr = of_translate_address(np, addrp);
if (taddr == OF_BAD_ADDR)
return NULL;
return ioremap(taddr + offset, size);
} }
static void __init offb_init_fb(const char *name, const char *full_name, static 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,7 +299,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
par->cmap_type = cmap_unknown; par->cmap_type = cmap_unknown;
if (depth == 8) { if (depth == 8) {
/* Palette hacks disabled for now */
if (dp && !strncmp(name, "ATY,Rage128", 11)) { if (dp && !strncmp(name, "ATY,Rage128", 11)) {
par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
if (par->cmap_adr) if (par->cmap_adr)
...@@ -313,7 +322,8 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -313,7 +322,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
ioremap(base + 0x7ff000, 0x1000) + 0xcc0; ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
par->cmap_data = par->cmap_adr + 1; par->cmap_data = par->cmap_adr + 1;
par->cmap_type = cmap_m64; par->cmap_type = cmap_m64;
} else if (dp && device_is_compatible(dp, "pci1014,b7")) { } else if (dp && (device_is_compatible(dp, "pci1014,b7") ||
device_is_compatible(dp, "pci1014,21c"))) {
par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
if (par->cmap_adr) if (par->cmap_adr)
par->cmap_type = cmap_gxt2000; par->cmap_type = cmap_gxt2000;
...@@ -433,7 +443,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) ...@@ -433,7 +443,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
pp = get_property(dp, "linux,bootx-linebytes", &len); pp = get_property(dp, "linux,bootx-linebytes", &len);
if (pp == NULL) if (pp == NULL)
pp = get_property(dp, "linebytes", &len); pp = get_property(dp, "linebytes", &len);
if (pp && len == sizeof(u32)) if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
pitch = *pp; pitch = *pp;
else else
pitch = width * ((depth + 7) / 8); pitch = width * ((depth + 7) / 8);
...@@ -496,7 +506,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) ...@@ -496,7 +506,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
offb_init_fb(no_real_node ? "bootx" : dp->name, offb_init_fb(no_real_node ? "bootx" : dp->name,
no_real_node ? "display" : dp->full_name, no_real_node ? "display" : dp->full_name,
width, height, depth, pitch, address, width, height, depth, pitch, address,
no_real_node ? dp : NULL); no_real_node ? NULL : dp);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment