* [PATCH net-next 1/4] net: renesas: rswitch: do not write to MPSM register at init time
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
@ 2024-12-08 15:52 ` Nikita Yushchenko
2024-12-08 15:52 ` [PATCH net-next 2/4] net: renesas: rswitch: align mdio C45 operations with datasheet Nikita Yushchenko
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nikita Yushchenko @ 2024-12-08 15:52 UTC (permalink / raw)
To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven
Cc: netdev, linux-renesas-soc, linux-kernel, Michael Dege,
Christian Mardmoeller, Dennis Ostermann, Nikita Yushchenko
MPSM register is used to execute mdio bus transactions.
There is no need to initialize it early.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/ethernet/renesas/rswitch.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 8ac6ef532c6a..57d0f992f9a5 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1139,7 +1139,6 @@ static void rswitch_etha_enable_mii(struct rswitch_etha *etha)
{
rswitch_modify(etha->addr, MPIC, MPIC_PSMCS_MASK | MPIC_PSMHT_MASK,
MPIC_PSMCS(etha->psmcs) | MPIC_PSMHT(0x06));
- rswitch_modify(etha->addr, MPSM, 0, MPSM_MFF_C45);
}
static int rswitch_etha_hw_init(struct rswitch_etha *etha, const u8 *mac)
--
2.39.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 2/4] net: renesas: rswitch: align mdio C45 operations with datasheet
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
2024-12-08 15:52 ` [PATCH net-next 1/4] net: renesas: rswitch: do not write to MPSM register at init time Nikita Yushchenko
@ 2024-12-08 15:52 ` Nikita Yushchenko
2024-12-08 15:52 ` [PATCH net-next 3/4] net: renesas: rswitch: use generic MPSM operation for mdio C45 Nikita Yushchenko
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nikita Yushchenko @ 2024-12-08 15:52 UTC (permalink / raw)
To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven
Cc: netdev, linux-renesas-soc, linux-kernel, Michael Dege,
Christian Mardmoeller, Dennis Ostermann, Nikita Yushchenko
Per rswitch datasheet, software can know that mdio operation completed
either by polling MPSM.PSME bit, or via interrupt.
Instead, the driver currently polls for interrupt status bit. Although
this still provides correct result, it requires additional register
operations to clean the interrupt status bits, and generally looks wrong.
Fix it to poll MPSM.PSME bit, as the datasheet suggests.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/ethernet/renesas/rswitch.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 57d0f992f9a5..120d56754692 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1177,32 +1177,26 @@ static int rswitch_etha_set_access(struct rswitch_etha *etha, bool read,
if (devad == 0xffffffff)
return -ENODEV;
- writel(MMIS1_CLEAR_FLAGS, etha->addr + MMIS1);
-
val = MPSM_PSME | MPSM_MFF_C45;
iowrite32((regad << 16) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM);
- ret = rswitch_reg_wait(etha->addr, MMIS1, MMIS1_PAACS, MMIS1_PAACS);
+ ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0);
if (ret)
return ret;
- rswitch_modify(etha->addr, MMIS1, MMIS1_PAACS, MMIS1_PAACS);
-
if (read) {
writel((pop << 13) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM);
- ret = rswitch_reg_wait(etha->addr, MMIS1, MMIS1_PRACS, MMIS1_PRACS);
+ ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0);
if (ret)
return ret;
ret = (ioread32(etha->addr + MPSM) & MPSM_PRD_MASK) >> 16;
-
- rswitch_modify(etha->addr, MMIS1, MMIS1_PRACS, MMIS1_PRACS);
} else {
iowrite32((data << 16) | (pop << 13) | (devad << 8) | (phyad << 3) | val,
etha->addr + MPSM);
- ret = rswitch_reg_wait(etha->addr, MMIS1, MMIS1_PWACS, MMIS1_PWACS);
+ ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0);
}
return ret;
--
2.39.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 3/4] net: renesas: rswitch: use generic MPSM operation for mdio C45
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
2024-12-08 15:52 ` [PATCH net-next 1/4] net: renesas: rswitch: do not write to MPSM register at init time Nikita Yushchenko
2024-12-08 15:52 ` [PATCH net-next 2/4] net: renesas: rswitch: align mdio C45 operations with datasheet Nikita Yushchenko
@ 2024-12-08 15:52 ` Nikita Yushchenko
2024-12-08 15:52 ` [PATCH net-next 4/4] net: renesas: rswitch: add mdio C22 support Nikita Yushchenko
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nikita Yushchenko @ 2024-12-08 15:52 UTC (permalink / raw)
To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven
Cc: netdev, linux-renesas-soc, linux-kernel, Michael Dege,
Christian Mardmoeller, Dennis Ostermann, Nikita Yushchenko
Introduce rswitch_etha_mpsm_op() that accepts values for MPSM register
fields and executes the transaction.
This avoids some code duptication, and can be used both for C45 and C22.
Convert C45 read and write operations to use that.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/ethernet/renesas/rswitch.c | 51 +++++++++++++++-----------
drivers/net/ethernet/renesas/rswitch.h | 17 ++++++---
2 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 120d56754692..8dc5ddfee01d 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1167,36 +1167,29 @@ static int rswitch_etha_hw_init(struct rswitch_etha *etha, const u8 *mac)
return rswitch_etha_change_mode(etha, EAMC_OPC_OPERATION);
}
-static int rswitch_etha_set_access(struct rswitch_etha *etha, bool read,
- int phyad, int devad, int regad, int data)
+static int rswitch_etha_mpsm_op(struct rswitch_etha *etha, bool read,
+ unsigned int mmf, unsigned int pda,
+ unsigned int pra, unsigned int pop,
+ unsigned int prd)
{
- int pop = read ? MDIO_READ_C45 : MDIO_WRITE_C45;
u32 val;
int ret;
- if (devad == 0xffffffff)
- return -ENODEV;
-
- val = MPSM_PSME | MPSM_MFF_C45;
- iowrite32((regad << 16) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM);
+ val = MPSM_PSME |
+ FIELD_PREP(MPSM_MFF, mmf) |
+ FIELD_PREP(MPSM_PDA, pda) |
+ FIELD_PREP(MPSM_PRA, pra) |
+ FIELD_PREP(MPSM_POP, pop) |
+ FIELD_PREP(MPSM_PRD, prd);
+ iowrite32(val, etha->addr + MPSM);
ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0);
if (ret)
return ret;
if (read) {
- writel((pop << 13) | (devad << 8) | (phyad << 3) | val, etha->addr + MPSM);
-
- ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0);
- if (ret)
- return ret;
-
- ret = (ioread32(etha->addr + MPSM) & MPSM_PRD_MASK) >> 16;
- } else {
- iowrite32((data << 16) | (pop << 13) | (devad << 8) | (phyad << 3) | val,
- etha->addr + MPSM);
-
- ret = rswitch_reg_wait(etha->addr, MPSM, MPSM_PSME, 0);
+ val = ioread32(etha->addr + MPSM);
+ ret = FIELD_GET(MPSM_PRD, val);
}
return ret;
@@ -1206,16 +1199,30 @@ static int rswitch_etha_mii_read_c45(struct mii_bus *bus, int addr, int devad,
int regad)
{
struct rswitch_etha *etha = bus->priv;
+ int ret;
- return rswitch_etha_set_access(etha, true, addr, devad, regad, 0);
+ ret = rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C45, addr, devad,
+ MPSM_POP_ADDRESS, regad);
+ if (ret)
+ return ret;
+
+ return rswitch_etha_mpsm_op(etha, true, MPSM_MMF_C45, addr, devad,
+ MPSM_POP_READ_C45, 0);
}
static int rswitch_etha_mii_write_c45(struct mii_bus *bus, int addr, int devad,
int regad, u16 val)
{
struct rswitch_etha *etha = bus->priv;
+ int ret;
+
+ ret = rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C45, addr, devad,
+ MPSM_POP_ADDRESS, regad);
+ if (ret)
+ return ret;
- return rswitch_etha_set_access(etha, false, addr, devad, regad, val);
+ return rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C45, addr, devad,
+ MPSM_POP_WRITE, val);
}
/* Call of_node_put(port) after done */
diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h
index 303883369b94..9ac55b4f5b14 100644
--- a/drivers/net/ethernet/renesas/rswitch.h
+++ b/drivers/net/ethernet/renesas/rswitch.h
@@ -732,13 +732,18 @@ enum rswitch_etha_mode {
#define MPIC_LSC_1G (2 << MPIC_LSC_SHIFT)
#define MPIC_LSC_2_5G (3 << MPIC_LSC_SHIFT)
-#define MDIO_READ_C45 0x03
-#define MDIO_WRITE_C45 0x01
-
#define MPSM_PSME BIT(0)
-#define MPSM_MFF_C45 BIT(2)
-#define MPSM_PRD_SHIFT 16
-#define MPSM_PRD_MASK GENMASK(31, MPSM_PRD_SHIFT)
+#define MPSM_MFF BIT(2)
+#define MPSM_MMF_C22 0
+#define MPSM_MMF_C45 1
+#define MPSM_PDA GENMASK(7, 3)
+#define MPSM_PRA GENMASK(12, 8)
+#define MPSM_POP GENMASK(14, 13)
+#define MPSM_POP_ADDRESS 0
+#define MPSM_POP_WRITE 1
+#define MPSM_POP_READ_C22 2
+#define MPSM_POP_READ_C45 3
+#define MPSM_PRD GENMASK(31, 16)
/* Completion flags */
#define MMIS1_PAACS BIT(2) /* Address */
--
2.39.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH net-next 4/4] net: renesas: rswitch: add mdio C22 support
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
` (2 preceding siblings ...)
2024-12-08 15:52 ` [PATCH net-next 3/4] net: renesas: rswitch: use generic MPSM operation for mdio C45 Nikita Yushchenko
@ 2024-12-08 15:52 ` Nikita Yushchenko
2024-12-10 12:08 ` [PATCH net-next 0/4] mdio support updates Yoshihiro Shimoda
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nikita Yushchenko @ 2024-12-08 15:52 UTC (permalink / raw)
To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven
Cc: netdev, linux-renesas-soc, linux-kernel, Michael Dege,
Christian Mardmoeller, Dennis Ostermann, Nikita Yushchenko
The generic MPSM operation added by the previous patch can be used both
for C45 and C22.
Add handlers for C22 operations.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/ethernet/renesas/rswitch.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 8dc5ddfee01d..444e7576b31c 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1225,6 +1225,23 @@ static int rswitch_etha_mii_write_c45(struct mii_bus *bus, int addr, int devad,
MPSM_POP_WRITE, val);
}
+static int rswitch_etha_mii_read_c22(struct mii_bus *bus, int phyad, int regad)
+{
+ struct rswitch_etha *etha = bus->priv;
+
+ return rswitch_etha_mpsm_op(etha, true, MPSM_MMF_C22, phyad, regad,
+ MPSM_POP_READ_C22, 0);
+}
+
+static int rswitch_etha_mii_write_c22(struct mii_bus *bus, int phyad,
+ int regad, u16 val)
+{
+ struct rswitch_etha *etha = bus->priv;
+
+ return rswitch_etha_mpsm_op(etha, false, MPSM_MMF_C22, phyad, regad,
+ MPSM_POP_WRITE, val);
+}
+
/* Call of_node_put(port) after done */
static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)
{
@@ -1307,6 +1324,8 @@ static int rswitch_mii_register(struct rswitch_device *rdev)
mii_bus->priv = rdev->etha;
mii_bus->read_c45 = rswitch_etha_mii_read_c45;
mii_bus->write_c45 = rswitch_etha_mii_write_c45;
+ mii_bus->read = rswitch_etha_mii_read_c22;
+ mii_bus->write = rswitch_etha_mii_write_c22;
mii_bus->parent = &rdev->priv->pdev->dev;
mdio_np = of_get_child_by_name(rdev->np_port, "mdio");
--
2.39.5
^ permalink raw reply related [flat|nested] 9+ messages in thread* RE: [PATCH net-next 0/4] mdio support updates
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
` (3 preceding siblings ...)
2024-12-08 15:52 ` [PATCH net-next 4/4] net: renesas: rswitch: add mdio C22 support Nikita Yushchenko
@ 2024-12-10 12:08 ` Yoshihiro Shimoda
2024-12-12 8:08 ` Paolo Abeni
2024-12-15 22:38 ` Jakub Kicinski
6 siblings, 0 replies; 9+ messages in thread
From: Yoshihiro Shimoda @ 2024-12-10 12:08 UTC (permalink / raw)
To: nikita.yoush, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven
Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org, Michael Dege, Christian Mardmoeller,
Dennis Ostermann, nikita.yoush
Hello Nikita-san,
> From: Nikita Yushchenko, Sent: Monday, December 9, 2024 12:53 AM
>
> This series cleans up rswitch mdio support, and adds C22 operations.
>
> Nikita Yushchenko (4):
> net: renesas: rswitch: do not write to MPSM register at init time
> net: renesas: rswitch: align mdio C45 operations with datasheet
> net: renesas: rswitch: use generic MPSM operation for mdio C45
> net: renesas: rswitch: add mdio C22 support
Thank you for the patches. They look good to me. So,
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
And, I tested the patches on my environment (R-Car S4 Spider), and
it worked without any regression. So,
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Best regards,
Yoshihiro Shimoda
> drivers/net/ethernet/renesas/rswitch.c | 79 ++++++++++++++++----------
> drivers/net/ethernet/renesas/rswitch.h | 17 ++++--
> 2 files changed, 60 insertions(+), 36 deletions(-)
>
> --
> 2.39.5
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH net-next 0/4] mdio support updates
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
` (4 preceding siblings ...)
2024-12-10 12:08 ` [PATCH net-next 0/4] mdio support updates Yoshihiro Shimoda
@ 2024-12-12 8:08 ` Paolo Abeni
2024-12-12 8:21 ` Yoshihiro Shimoda
2024-12-15 22:38 ` Jakub Kicinski
6 siblings, 1 reply; 9+ messages in thread
From: Paolo Abeni @ 2024-12-12 8:08 UTC (permalink / raw)
To: Yoshihiro Shimoda
Cc: netdev, linux-renesas-soc, linux-kernel, Michael Dege,
Christian Mardmoeller, Dennis Ostermann, Nikita Yushchenko,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Geert Uytterhoeven
On 12/8/24 16:52, Nikita Yushchenko wrote:
> This series cleans up rswitch mdio support, and adds C22 operations.
>
> Nikita Yushchenko (4):
> net: renesas: rswitch: do not write to MPSM register at init time
> net: renesas: rswitch: align mdio C45 operations with datasheet
> net: renesas: rswitch: use generic MPSM operation for mdio C45
> net: renesas: rswitch: add mdio C22 support
>
> drivers/net/ethernet/renesas/rswitch.c | 79 ++++++++++++++++----------
> drivers/net/ethernet/renesas/rswitch.h | 17 ++++--
> 2 files changed, 60 insertions(+), 36 deletions(-)
@Yoshihiro, could you please have a look here?
Thanks,
Paolo
^ permalink raw reply [flat|nested] 9+ messages in thread* RE: [PATCH net-next 0/4] mdio support updates
2024-12-12 8:08 ` Paolo Abeni
@ 2024-12-12 8:21 ` Yoshihiro Shimoda
0 siblings, 0 replies; 9+ messages in thread
From: Yoshihiro Shimoda @ 2024-12-12 8:21 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org, Michael Dege, Christian Mardmoeller,
Dennis Ostermann, nikita.yoush, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Geert Uytterhoeven
Hello Paolo,
> From: Paolo Abeni, Sent: Thursday, December 12, 2024 5:08 PM
>
> On 12/8/24 16:52, Nikita Yushchenko wrote:
> > This series cleans up rswitch mdio support, and adds C22 operations.
> >
> > Nikita Yushchenko (4):
> > net: renesas: rswitch: do not write to MPSM register at init time
> > net: renesas: rswitch: align mdio C45 operations with datasheet
> > net: renesas: rswitch: use generic MPSM operation for mdio C45
> > net: renesas: rswitch: add mdio C22 support
> >
> > drivers/net/ethernet/renesas/rswitch.c | 79 ++++++++++++++++----------
> > drivers/net/ethernet/renesas/rswitch.h | 17 ++++--
> > 2 files changed, 60 insertions(+), 36 deletions(-)
>
> @Yoshihiro, could you please have a look here?
I have already reviewed and tested these patches, and sent an email as following:
https://lore.kernel.org/all/TYCPR01MB1104066D4705868EEA440CE13D83D2@TYCPR01MB11040.jpnprd01.prod.outlook.com/
Best regards,
Yoshihiro Shimoda
> Thanks,
>
> Paolo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 0/4] mdio support updates
2024-12-08 15:52 [PATCH net-next 0/4] mdio support updates Nikita Yushchenko
` (5 preceding siblings ...)
2024-12-12 8:08 ` Paolo Abeni
@ 2024-12-15 22:38 ` Jakub Kicinski
6 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2024-12-15 22:38 UTC (permalink / raw)
To: Nikita Yushchenko
Cc: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, Geert Uytterhoeven, netdev, linux-renesas-soc,
linux-kernel, Michael Dege, Christian Mardmoeller,
Dennis Ostermann
On Sun, 8 Dec 2024 20:52:32 +0500 Nikita Yushchenko wrote:
> This series cleans up rswitch mdio support, and adds C22 operations.
This series doesn't apply any more, please rebase / repost.
--
pw-bot: nap
^ permalink raw reply [flat|nested] 9+ messages in thread