Endianness versus too many byte swaps??

Charles Krinke ckrinke at istor.com
Sun Mar 4 06:58:45 EST 2007


This is probably a Timur question, but any enlightment is appreciated. This concerns Linux-2.6.17.11 from kernel.org with some modifications for our custom 8541 board. The original BSP was evolved from mpc85xx_cds.
 
Down in the guts of arch/ppc/syslib/ppc85xx_seteup.c is a routine called mpc85xx_setup_pci1(). In this routine we do an assignment of some outbound window registers and I am most interested in POTAR2, POWAR2 & POWBAR2 right now.
 
This routine uses a ccsr_pci struct to assign potar2, powar2, powbar2 and others like this:
 
pci->potar2     = 0x00100000;
pci->powar2   = 0x8004401a;
pci->powbar2 = 0x00888000;
 
Where I have changed the constants for our board. The issue is that when I call readl to read back these same registers at the end of this same subroutine, I get into endianess issues. That is, I read back
 
POTAR2     == 0x00001000
POWAR2   == 0x1A400480
POWBAR2 == 0x00800800
 
Where the four bytes in each 32bit word are now exchanged so that 80_04_40_1A became 1A_40_04_80.
 
I understand big versus little endian, that isn't the question. The question is "What is really in the POTAR2, POWAR2 & POWBAR2 registers and how can I prove that what is in the registers is really what I wish to be in the registers?"
 
It may be that one or more endian swap things are going on within Linux and I have inherited some source from others, so actually proving what is in the registers is becoming important.
 
Charles



More information about the Linuxppc-embedded mailing list