Re: [PATCHv3 1/3] net: fec: do not use readl()/writel() for ColdFire

From: Greg Ungerer

Date: Mon Sep 28 2026 - 09:57:56 EST



On 24/9/26 00:15, Andrew Lunn wrote:
>> The driver will always need to support big and little endian hardware, so I
>> am not sure how to avoid some abstraction like this.
>
> I was wondering if there is a linux standard set of macros which is
> supposed to handle this big/little difference, the macro knows the
> architecture and does the correct thing?

There is regmap, but that is way more than just access macros.
At least one driver shared across big and little endian architectures
does use that - the freescale dspi driver (drivers/spi/spi-fsl-dspi.c).
There is probably others.

If the issue is more to do with code churn then a simpler approach here
might be to just essentially keep the same work around but move it locally
into fec.h. Something like the patch below.

This could be cleaned up to use ioread32be()/iowrite32be() after the final
readl()/writel() changes have been applied.

Regards
Greg



diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 7176803146f3..317e4e44d313 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -701,5 +701,16 @@ int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack);
void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config *config);

+/*
+ * ColdFire SoC peripheral blocks are big-endian, so use the raw IO access
+ * functions for them to access in correct byte order.
+ */
+#ifdef CONFIG_COLDFIRE
+#undef readl
+#define readl __raw_readl
+#undef writel
+#define writel __raw_writel
+#endif
+
/****************************************************************************/
#endif /* FEC_H */