[U-Boot] [PATCH] drivers/block/systemace: replaced in16/out16 with more common readw/writew macros

Алексей Бродкин alexey.brodkin at gmail.com
Thu Jan 3 12:35:44 CET 2013


Unfortunately I didn't test it on any BE hardware - I don't have
anything handy at the moment.
I got it tested on LE platform - though it has nothing to do with real
BE behavior.

But as far as I can see from kernel headers "writew" does this -
regardless CPU endianess it writes 16-bit word to specified memory
location in LE order.
http://lxr.free-electrons.com/source/arch/microblaze/include/asm/io.h#L96
====
static inline void writew(unsigned short v, volatile void __iomem *addr)
{
         *(volatile unsigned short __force *)addr = cpu_to_le16(v);
}
====

So depending on SystemACE internal endianess we may or may not use "writew".
If SystemACE is always LE then "writew"/"readw" will do its work as expected.
If SystemACE has the same endianess as CPU does then we may use
"__raw_writew"/"__raw_readw" for data access.

But here http://www.xilinx.com/support/documentation/ip_documentation/xps_sysace.pdf
it is said:
====
The Xilinx System ACE Compact Flash chip is a true little-endian device.
====

So I expect "writew"/"readw" to work correctly assuming not
intermediate bridge is put between CPU and System ACE controller.

Would be very nice if Michal may check it on his hardware and let us
know about his findings.

2013/1/3 Wolfgang Denk <wd at denx.de>:
> Dear Alexey Brodkin,
>
> In message <1357139186-9172-1-git-send-email-alexey.brodkin at gmail.com> you wrote:
>> Most architectures don't have symbols "in16"/"out16" defined.
>> Only Microblaze/PowerPC/Spark architectures do have them defined.
>>
>> At the same time there're much more common macros "readw"/"writew" for
>> 16-bit data access defined in most of architectures (in
>> linux kernel header "io.h").
>>
>> So use of "readw"/"writew" makes it possible to build this driver for
>> virtually any architecture.
>>
>> Signed-off-by: Alexey Brodkin <alexey.brodkin at gmail.com>
>
> Did you actually test this on - say - any PowerPC board?
>
> To my understanding, in16() / out16() perform big endian accesses
> (i. e. direct load / store operations) on PowerPC, while readw /
> writew do byte-swapping (for accessling little-endian things like PCI
> busses).
>
> I speculate that this patch will break all big-endian systems.
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> "There are three principal ways to lose money: wine, women, and engi-
> neers. While the first two are more pleasant, the third is by far the
> more certain."                           - Baron Rothschild, ca. 1800


More information about the U-Boot mailing list