The forwarding engine CSD register offset changed between the
R-Car S4 and R-Car X5H. Parametrize this offset in preparation
for R-Car X5H addition into this driver. Clean up the macro
parameter names and make them more obvious. No functional change.

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Jerome Forissier <[email protected]>
Cc: Joe Hershberger <[email protected]>
Cc: Nobuhiro Iwamatsu <[email protected]>
Cc: Paul Barker <[email protected]>
Cc: Ramon Fried <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
 drivers/net/rswitch.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/rswitch.c b/drivers/net/rswitch.c
index 419293091f6..096e1c99220 100644
--- a/drivers/net/rswitch.c
+++ b/drivers/net/rswitch.c
@@ -111,8 +111,9 @@
                                 FWPC0_IPDSA | FWPC0_IPHLA | FWPC0_MACSDA | \
                                 FWPC0_MACHLA | FWPC0_MACHMA | FWPC0_VLANSA)
 
-#define FWPBFC(i)      (FWPBFCR + (i) * 0x10)
-#define FWPBFCSDC(j, i)        (FWPBFCSDCR + (i) * 0x10 + (j) * 0x04)
+#define FWPBFC(i)              (FWPBFCR + (i) * 0x10)
+#define FWPBFCSDC(gwcaidx, ethaidx, ethaincr)          \
+       (FWPBFCSDCR + (ethaidx) * (ethaincr) + (gwcaidx) * 0x04)
 
 /* ETHA */
 #define EATASRIRM_TASRIOG      BIT(0)
@@ -282,6 +283,7 @@ struct rswitch_drv_data {
        u32                     coma_offset;
        u32                     etha_offset;
        u32                     gwca_offset;
+       u8                      etha_incr;
        int                     ports;
 };
 
@@ -682,7 +684,8 @@ static void rswitch_mfwd_init(struct rswitch_port_priv 
*priv)
        writel(FWPC0_DEFAULT, priv->addr + FWPC0(gwca->index));
 
        writel(RSWITCH_RX_CHAIN_INDEX,
-              priv->addr + FWPBFCSDC(gwca_index, etha_index));
+              priv->addr + FWPBFCSDC(gwca_index, etha_index,
+                                     priv->drv_data->etha_incr));
 
        writel(BIT(gwca->index),
               priv->addr + FWPBFC(etha_index));
@@ -1195,6 +1198,7 @@ static const struct rswitch_drv_data r8a779f0_drv_data = {
        .coma_offset    = 0x9000,
        .etha_offset    = 0xa000,
        .gwca_offset    = 0x10000,
+       .etha_incr      = 0x10,
 };
 
 static const struct udevice_id rswitch_ids[] = {
-- 
2.51.0

Reply via email to