[PATCH v2 2/5] m68k: Fix writew(), writel(), readw(), readl() endianness
Angelo Dureghello
angelo at kernel-space.org
Wed Apr 8 16:18:35 CEST 2026
Hi Daniel,
On 4/8/26 15:40, Daniel Palmer wrote:
> Hi Angelo,
>
> On Wed, 8 Apr 2026 at 22:26, Angelo Dureghello <angelo at kernel-space.org> wrote:
>> yes, thanks, please try to find a solution protecting coldfire for now.
>
> So for now I have put #ifdefs in so coldfire retains its current behaviour.
>
>> I will try to understand better why Linux operates differently from u-boot,
>> i think pci was involved here but actually i don't remember, need to
>> study this deeper.
>
> I thought maybe this change in m68k might be recent but in Linux it
> seems to have been there since the import into git 22 years ago.
>
> In the linux docs (https://docs.kernel.org/driver-api/device-io.html)
> it says this:
>
> Note: On some architectures, the normal readl()/writel() functions
> traditionally assume that devices are the same endianness as the CPU,
> while using a hardware byte-reverse on the PCI bus when running a
> big-endian kernel. Drivers that use readl()/writel() this way are
> generally not portable, but tend to be limited to a particular SoC.
>
> So I think maybe coldfire got a "reads native endian, no swap"
> readl()/writel() and then when PCI support was added a hack was
> needed. But somehow normal m68k got it the other way around. <shrug>
mmm, so from a fast look:
apart for M5235EVB_defconfig:CONFIG_CMD_PCI=y
but this board has no PCI bus, so it should be some config copy/paste,
there is no other board using pci for coldfire, maybe either no pci driver
working (NXP driver may work ?) or tested for them, so there was never
any need for swapping LE for pci. But just an assumption, i can be totally
wrong since some nxp board has been removed and some coldfire have pci.
So this part
#if !defined(__BIG_ENDIAN)
#define readw(addr) (*(volatile u16 *) (addr))
#define readl(addr) (*(volatile u32 *) (addr))
#define writew(b,addr) ((*(volatile u16 *) (addr)) = (b))
#define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
#else
is probably non functional from a pci driver since still "be" r/w. Should
be replaced with _le stuff. But should go deeper when i have some time.
>
> Anyhow, sorry again for breaking your board.
>
as i said, no problem. We tested it before, that's ok.
> Cheers,
>
> Daniel
Regards,
-- Angelo
More information about the U-Boot
mailing list