lkml.org 
[lkml]   [2020]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH net-next] net: macb: add support for C45 MDIO read/write
Date
Le jeudi 09 janvier 2020 à 08:36 +0000, Milind Parab a écrit :
> This patch modify MDIO read/write functions to support
> communication with C45 PHY.
>
> Signed-off-by: Milind Parab <mparab@cadence.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Thanks Milind. Best regards,
Nicolas

> ---
> drivers/net/ethernet/cadence/macb.h | 15 ++++--
> drivers/net/ethernet/cadence/macb_main.c | 61 +++++++++++++++++++-----
> 2 files changed, 61 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.h
> b/drivers/net/ethernet/cadence/macb.h
> index 19fe4f4867c7..dbf7070fcdba 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -630,10 +630,17 @@
> #define GEM_CLK_DIV96 5
>
> /* Constants for MAN register */
> -#define MACB_MAN_SOF 1
> -#define MACB_MAN_WRITE 1
> -#define MACB_MAN_READ 2
> -#define MACB_MAN_CODE 2
> +#define MACB_MAN_C22_SOF 1
> +#define MACB_MAN_C22_WRITE 1
> +#define MACB_MAN_C22_READ 2
> +#define MACB_MAN_C22_CODE 2
> +
> +#define MACB_MAN_C45_SOF 0
> +#define MACB_MAN_C45_ADDR 0
> +#define MACB_MAN_C45_WRITE 1
> +#define MACB_MAN_C45_POST_READ_INCR 2
> +#define MACB_MAN_C45_READ 3
> +#define MACB_MAN_C45_CODE 2
>
> /* Capability mask bits */
> #define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001
> diff --git a/drivers/net/ethernet/cadence/macb_main.c
> b/drivers/net/ethernet/cadence/macb_main.c
> index 41c485485619..7e7361761f8f 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -337,11 +337,30 @@ static int macb_mdio_read(struct mii_bus *bus, int
> mii_id, int regnum)
> if (status < 0)
> goto mdio_read_exit;
>
> - macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF)
> - | MACB_BF(RW, MACB_MAN_READ)
> - | MACB_BF(PHYA, mii_id)
> - | MACB_BF(REGA, regnum)
> - | MACB_BF(CODE, MACB_MAN_CODE)));
> + if (regnum & MII_ADDR_C45) {
> + macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
> + | MACB_BF(RW, MACB_MAN_C45_ADDR)
> + | MACB_BF(PHYA, mii_id)
> + | MACB_BF(REGA, (regnum >> 16) & 0x1F)
> + | MACB_BF(DATA, regnum & 0xFFFF)
> + | MACB_BF(CODE, MACB_MAN_C45_CODE)));
> +
> + status = macb_mdio_wait_for_idle(bp);
> + if (status < 0)
> + goto mdio_read_exit;
> +
> + macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
> + | MACB_BF(RW, MACB_MAN_C45_READ)
> + | MACB_BF(PHYA, mii_id)
> + | MACB_BF(REGA, (regnum >> 16) & 0x1F)
> + | MACB_BF(CODE, MACB_MAN_C45_CODE)));
> + } else {
> + macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C22_SOF)
> + | MACB_BF(RW, MACB_MAN_C22_READ)
> + | MACB_BF(PHYA, mii_id)
> + | MACB_BF(REGA, regnum)
> + | MACB_BF(CODE, MACB_MAN_C22_CODE)));
> + }
>
> status = macb_mdio_wait_for_idle(bp);
> if (status < 0)
> @@ -370,12 +389,32 @@ static int macb_mdio_write(struct mii_bus *bus, int
> mii_id, int regnum,
> if (status < 0)
> goto mdio_write_exit;
>
> - macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF)
> - | MACB_BF(RW, MACB_MAN_WRITE)
> - | MACB_BF(PHYA, mii_id)
> - | MACB_BF(REGA, regnum)
> - | MACB_BF(CODE, MACB_MAN_CODE)
> - | MACB_BF(DATA, value)));
> + if (regnum & MII_ADDR_C45) {
> + macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
> + | MACB_BF(RW, MACB_MAN_C45_ADDR)
> + | MACB_BF(PHYA, mii_id)
> + | MACB_BF(REGA, (regnum >> 16) & 0x1F)
> + | MACB_BF(DATA, regnum & 0xFFFF)
> + | MACB_BF(CODE, MACB_MAN_C45_CODE)));
> +
> + status = macb_mdio_wait_for_idle(bp);
> + if (status < 0)
> + goto mdio_write_exit;
> +
> + macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C45_SOF)
> + | MACB_BF(RW, MACB_MAN_C45_WRITE)
> + | MACB_BF(PHYA, mii_id)
> + | MACB_BF(REGA, (regnum >> 16) & 0x1F)
> + | MACB_BF(CODE, MACB_MAN_C45_CODE)
> + | MACB_BF(DATA, value)));
> + } else {
> + macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_C22_SOF)
> + | MACB_BF(RW, MACB_MAN_C22_WRITE)
> + | MACB_BF(PHYA, mii_id)
> + | MACB_BF(REGA, regnum)
> + | MACB_BF(CODE, MACB_MAN_C22_CODE)
> + | MACB_BF(DATA, value)));
> + }
>
> status = macb_mdio_wait_for_idle(bp);
> if (status < 0)
> --
> 2.17.1
>
\
 
 \ /
  Last update: 2020-01-09 14:00    [W:0.075 / U:9.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site