diff options
author | Cedric Le Goater <clg@fr.ibm.com> | 2013-12-04 11:49:51 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-12-09 19:25:06 -0500 |
commit | 212c0cbd5be721a39ef3e2f723e0c78008f9e955 (patch) | |
tree | 1bd0ccf4aebe577f986afbb12bed89180e1563ba | |
parent | cf77ee54362a245f9a01f240adce03a06c05eb68 (diff) |
offb: Little endian fixes
The "screen" properties : depth, width, height, linebytes need
to be converted to the host endian order when read from the device
tree.
The offb_init_palette_hacks() routine also made assumption on the
host endian order.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | drivers/video/offb.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/video/offb.c b/drivers/video/offb.c index 9dbea2223401..43a0a52fc527 100644 --- a/drivers/video/offb.c +++ b/drivers/video/offb.c | |||
@@ -301,7 +301,7 @@ static struct fb_ops offb_ops = { | |||
301 | static void __iomem *offb_map_reg(struct device_node *np, int index, | 301 | static void __iomem *offb_map_reg(struct device_node *np, int index, |
302 | unsigned long offset, unsigned long size) | 302 | unsigned long offset, unsigned long size) |
303 | { | 303 | { |
304 | const u32 *addrp; | 304 | const __be32 *addrp; |
305 | u64 asize, taddr; | 305 | u64 asize, taddr; |
306 | unsigned int flags; | 306 | unsigned int flags; |
307 | 307 | ||
@@ -369,7 +369,11 @@ static void offb_init_palette_hacks(struct fb_info *info, struct device_node *dp | |||
369 | } | 369 | } |
370 | of_node_put(pciparent); | 370 | of_node_put(pciparent); |
371 | } else if (dp && of_device_is_compatible(dp, "qemu,std-vga")) { | 371 | } else if (dp && of_device_is_compatible(dp, "qemu,std-vga")) { |
372 | const u32 io_of_addr[3] = { 0x01000000, 0x0, 0x0 }; | 372 | #ifdef __BIG_ENDIAN |
373 | const __be32 io_of_addr[3] = { 0x01000000, 0x0, 0x0 }; | ||
374 | #else | ||
375 | const __be32 io_of_addr[3] = { 0x00000001, 0x0, 0x0 }; | ||
376 | #endif | ||
373 | u64 io_addr = of_translate_address(dp, io_of_addr); | 377 | u64 io_addr = of_translate_address(dp, io_of_addr); |
374 | if (io_addr != OF_BAD_ADDR) { | 378 | if (io_addr != OF_BAD_ADDR) { |
375 | par->cmap_adr = ioremap(io_addr + 0x3c8, 2); | 379 | par->cmap_adr = ioremap(io_addr + 0x3c8, 2); |
@@ -535,7 +539,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) | |||
535 | unsigned int flags, rsize, addr_prop = 0; | 539 | unsigned int flags, rsize, addr_prop = 0; |
536 | unsigned long max_size = 0; | 540 | unsigned long max_size = 0; |
537 | u64 rstart, address = OF_BAD_ADDR; | 541 | u64 rstart, address = OF_BAD_ADDR; |
538 | const u32 *pp, *addrp, *up; | 542 | const __be32 *pp, *addrp, *up; |
539 | u64 asize; | 543 | u64 asize; |
540 | int foreign_endian = 0; | 544 | int foreign_endian = 0; |
541 | 545 | ||
@@ -551,25 +555,25 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) | |||
551 | if (pp == NULL) | 555 | if (pp == NULL) |
552 | pp = of_get_property(dp, "depth", &len); | 556 | pp = of_get_property(dp, "depth", &len); |
553 | if (pp && len == sizeof(u32)) | 557 | if (pp && len == sizeof(u32)) |
554 | depth = *pp; | 558 | depth = be32_to_cpup(pp); |
555 | 559 | ||
556 | pp = of_get_property(dp, "linux,bootx-width", &len); | 560 | pp = of_get_property(dp, "linux,bootx-width", &len); |
557 | if (pp == NULL) | 561 | if (pp == NULL) |
558 | pp = of_get_property(dp, "width", &len); | 562 | pp = of_get_property(dp, "width", &len); |
559 | if (pp && len == sizeof(u32)) | 563 | if (pp && len == sizeof(u32)) |
560 | width = *pp; | 564 | width = be32_to_cpup(pp); |
561 | 565 | ||
562 | pp = of_get_property(dp, "linux,bootx-height", &len); | 566 | pp = of_get_property(dp, "linux,bootx-height", &len); |
563 | if (pp == NULL) | 567 | if (pp == NULL) |
564 | pp = of_get_property(dp, "height", &len); | 568 | pp = of_get_property(dp, "height", &len); |
565 | if (pp && len == sizeof(u32)) | 569 | if (pp && len == sizeof(u32)) |
566 | height = *pp; | 570 | height = be32_to_cpup(pp); |
567 | 571 | ||
568 | pp = of_get_property(dp, "linux,bootx-linebytes", &len); | 572 | pp = of_get_property(dp, "linux,bootx-linebytes", &len); |
569 | if (pp == NULL) | 573 | if (pp == NULL) |
570 | pp = of_get_property(dp, "linebytes", &len); | 574 | pp = of_get_property(dp, "linebytes", &len); |
571 | if (pp && len == sizeof(u32) && (*pp != 0xffffffffu)) | 575 | if (pp && len == sizeof(u32) && (*pp != 0xffffffffu)) |
572 | pitch = *pp; | 576 | pitch = be32_to_cpup(pp); |
573 | else | 577 | else |
574 | pitch = width * ((depth + 7) / 8); | 578 | pitch = width * ((depth + 7) / 8); |
575 | 579 | ||