Davicom DM9000A on MPC5200B (powerpc) works using a dirty offsetting and byte trick

Juergen Beisert jbe at pengutronix.de
Mon Mar 9 22:09:34 EST 2009


Henk,

On Montag, 9. März 2009, Henk Stegeman wrote:
> I don't understand how this would work,
>
> Now I do one byte-swap, which works.
>  -I byteswap in software, for 16-bit cycles by byte swapping and for 8
> bit cycles by adding an offset of 1.
>  (The byte swapping on the chipselect is off)
>
> Your advice includes two byteswaps, one by re-routing the data bus and
> one by enabling the byte swap on the chip-select.

My experience is the chip select byte swap feature only works correctly if you 
connect a little endian device like I showed you.

> Or does one of them not really swap bytes?

Let me show you how it works. You must ensure you can write/read data in any 
data width, but at the side of the little endian device it always must be in 
the correct endianess. This example uses a 32 bit data width, but it works 
for 16 bit, too.
- LE shows how a real litte endian CPU would write data
- MPC1 shows how MPC5200 will do it, without any byte swap and DO at the
  MPC5200 side is also D0 at the little endian device
- MPC2 shows how MPC5200 will do it, with D0 at the MPC5200 side is D24 at the
  little endian device
- MPC3 shows how MPC5200 will do it, connected like MPC2 but also the chip
  select byte swap feature enabled
- LE DEV shows how the little endian device expects the data

You want to write this data at the given offset into the little endian device:

 Bytes: 0:0x34, 1:0x12, 2:0x78, 3:0x56
 Worte:     0:0x1234       2:0x5678
 LONG:            0:0x56781234

Writing as bytes:

 Bytes: 0:0x34, 1:0x12, 2:0x78, 3:0x56

Offset  LE    MPC1  MPC2  MPC3  LE DEV
 0      0x34  0x56  0x34  0x34  0x34
 1      0x12  0x78  0x12  0x12  0x12
 2      0x78  0x12  0x78  0x78  0x78
 3      0x56  0x34  0x56  0x56  0x56
        ^^^^--------^^^^--^^^^--^^^^--> these are correct
              ^^^^--------------------> this is wrong

Writing as words:

 Words:     0:0x1234       2:0x5678

Offset   LE     MPC1  MPC2  MPC3  LE DEV
  0      0x34   0x78  0x12  0x34  0x34
 (1)     0x12   0x56  0x34  0x12  0x12
  2      0x78   0x34  0x56  0x78  0x78
 (3)     0x56   0x12  0x78  0x56  0x56
         ^^^^---------------^^^^--^^^^--> these are correct
                ^^^^--^^^^--------------> these are wrong

Writing as longs:

 LONG:         0:0x56781234

Offset   LE     MPC1  MPC2  MPC3  LE DEV
  0      0x34   0x34  0x56  0x34  0x34
 (1)     0x12   0x12  0x78  0x12  0x12
 (2)     0x78   0x78  0x12  0x78  0x78
 (3)     0x56   0x56  0x34  0x56  0x56
         ^^^^---^^^^ -------^^^^--^^^^--> these are correct
                      ^^^^--------------> this is wrong

So, the MPC3 example always writes correct data.

Hope it helps,
Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |



More information about the Linuxppc-dev mailing list