diff mbox series

[PATCHv3,04/15] net: tsec: Add the compatible string "gianfar" support

Message ID 20200612151735.49048-5-Zhiqiang.Hou@nxp.com
State Superseded
Headers show
Series powerpc: covert p1010, p1020 and p2020 RDB board to DM_ETH | expand

Commit Message

Zhiqiang Hou June 12, 2020, 3:17 p.m. UTC
From: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>

Add compatible string "gianfar" support and update the
device-tree-bindings doc.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
---
V3:
 - Rebase the patch, no change intended.

 doc/device-tree-bindings/net/fsl-tsec-phy.txt |  2 +-
 drivers/net/tsec.c                            | 16 ++++++++++++++--
 include/tsec.h                                |  4 ++++
 3 files changed, 19 insertions(+), 3 deletions(-)

Comments

Vladimir Oltean June 12, 2020, 8:40 p.m. UTC | #1
On Fri, 12 Jun 2020 at 18:23, Zhiqiang Hou <Zhiqiang.Hou at nxp.com> wrote:
>
> From: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
>
> Add compatible string "gianfar" support and update the
> device-tree-bindings doc.
>
> Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean at nxp.com>

> V3:
>  - Rebase the patch, no change intended.
>
>  doc/device-tree-bindings/net/fsl-tsec-phy.txt |  2 +-
>  drivers/net/tsec.c                            | 16 ++++++++++++++--
>  include/tsec.h                                |  4 ++++
>  3 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/doc/device-tree-bindings/net/fsl-tsec-phy.txt b/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> index 8e8574bc97..a44c5fd9d9 100644
> --- a/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> +++ b/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> @@ -2,7 +2,7 @@
>
>  Properties:
>
> -  - compatible : Should be "fsl,etsec2"
> +  - compatible : Should be "fsl,etsec2" or "gianfar"
>    - reg : Offset and length of the register set for the device
>    - phy-handle : See ethernet.txt file in the same directory.
>    - phy-connection-type : See ethernet.txt file in the same directory. This
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index cb3e56d439..22658506b2 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -806,11 +806,14 @@ int tsec_probe(struct udevice *dev)
>         struct tsec_private *priv = dev_get_priv(dev);
>         struct ofnode_phandle_args phandle_args;
>         u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
> +       struct tsec_data *data;
>         const char *phy_mode;
>         fdt_addr_t reg;
>         ofnode parent;
>         int ret;
>
> +       data = (struct tsec_data *)dev_get_driver_data(dev);
> +
>         pdata->iobase = (phys_addr_t)dev_read_addr(dev);
>         priv->regs = dev_remap_addr(dev);
>
> @@ -831,7 +834,7 @@ int tsec_probe(struct udevice *dev)
>                         return -ENOENT;
>                 }
>
> -               priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET,
> +               priv->phyregs_sgmii = map_physmem(reg + data->mdio_regs_off,
>                                                   0, MAP_NOCACHE);
>         }
>
> @@ -883,8 +886,17 @@ static const struct eth_ops tsec_ops = {
>         .mcast = tsec_mcast_addr,
>  };
>
> +static struct tsec_data etsec2_data = {
> +       .mdio_regs_off = TSEC_MDIO_REGS_OFFSET,
> +};
> +
> +static struct tsec_data gianfar_data = {
> +       .mdio_regs_off = 0x0,
> +};
> +
>  static const struct udevice_id tsec_ids[] = {
> -       { .compatible = "fsl,etsec2" },
> +       { .compatible = "fsl,etsec2", .data = (ulong)&etsec2_data },
> +       { .compatible = "gianfar", .data = (ulong)&gianfar_data },
>         { }
>  };
>
> diff --git a/include/tsec.h b/include/tsec.h
> index b17fa957df..047dd3c373 100644
> --- a/include/tsec.h
> +++ b/include/tsec.h
> @@ -394,6 +394,10 @@ struct tsec {
>
>  #define TX_BUF_CNT     2
>
> +struct tsec_data {
> +       u32 mdio_regs_off;
> +};
> +
>  struct tsec_private {
>         struct txbd8 __iomem txbd[TX_BUF_CNT];
>         struct rxbd8 __iomem rxbd[PKTBUFSRX];
> --
> 2.25.1
>
Zhiqiang Hou June 15, 2020, 8:56 a.m. UTC | #2
Hi Vladimir,

Thanks a lot for your review!

Regards,
Zhiqiang

> -----Original Message-----
> From: Vladimir Oltean <olteanv at gmail.com>
> Sent: 2020?6?13? 4:40
> To: Z.q. Hou <zhiqiang.hou at nxp.com>
> Cc: u-boot <u-boot at lists.denx.de>; Priyanka Jain <priyanka.jain at nxp.com>;
> Bin Meng <bmeng.cn at gmail.com>
> Subject: Re: [PATCHv3 04/15] net: tsec: Add the compatible string "gianfar"
> support
> 
> On Fri, 12 Jun 2020 at 18:23, Zhiqiang Hou <Zhiqiang.Hou at nxp.com> wrote:
> >
> > From: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
> >
> > Add compatible string "gianfar" support and update the
> > device-tree-bindings doc.
> >
> > Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
> > ---
> 
> Reviewed-by: Vladimir Oltean <vladimir.oltean at nxp.com>
> 
> > V3:
> >  - Rebase the patch, no change intended.
> >
> >  doc/device-tree-bindings/net/fsl-tsec-phy.txt |  2 +-
> >  drivers/net/tsec.c                            | 16
> ++++++++++++++--
> >  include/tsec.h                                |  4 ++++
> >  3 files changed, 19 insertions(+), 3 deletions(-)
> >
> > diff --git a/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> > b/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> > index 8e8574bc97..a44c5fd9d9 100644
> > --- a/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> > +++ b/doc/device-tree-bindings/net/fsl-tsec-phy.txt
> > @@ -2,7 +2,7 @@
> >
> >  Properties:
> >
> > -  - compatible : Should be "fsl,etsec2"
> > +  - compatible : Should be "fsl,etsec2" or "gianfar"
> >    - reg : Offset and length of the register set for the device
> >    - phy-handle : See ethernet.txt file in the same directory.
> >    - phy-connection-type : See ethernet.txt file in the same
> > directory. This diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> > index cb3e56d439..22658506b2 100644
> > --- a/drivers/net/tsec.c
> > +++ b/drivers/net/tsec.c
> > @@ -806,11 +806,14 @@ int tsec_probe(struct udevice *dev)
> >         struct tsec_private *priv = dev_get_priv(dev);
> >         struct ofnode_phandle_args phandle_args;
> >         u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
> > +       struct tsec_data *data;
> >         const char *phy_mode;
> >         fdt_addr_t reg;
> >         ofnode parent;
> >         int ret;
> >
> > +       data = (struct tsec_data *)dev_get_driver_data(dev);
> > +
> >         pdata->iobase = (phys_addr_t)dev_read_addr(dev);
> >         priv->regs = dev_remap_addr(dev);
> >
> > @@ -831,7 +834,7 @@ int tsec_probe(struct udevice *dev)
> >                         return -ENOENT;
> >                 }
> >
> > -               priv->phyregs_sgmii = map_physmem(reg +
> TSEC_MDIO_REGS_OFFSET,
> > +               priv->phyregs_sgmii = map_physmem(reg +
> > + data->mdio_regs_off,
> >                                                   0,
> MAP_NOCACHE);
> >         }
> >
> > @@ -883,8 +886,17 @@ static const struct eth_ops tsec_ops = {
> >         .mcast = tsec_mcast_addr,
> >  };
> >
> > +static struct tsec_data etsec2_data = {
> > +       .mdio_regs_off = TSEC_MDIO_REGS_OFFSET, };
> > +
> > +static struct tsec_data gianfar_data = {
> > +       .mdio_regs_off = 0x0,
> > +};
> > +
> >  static const struct udevice_id tsec_ids[] = {
> > -       { .compatible = "fsl,etsec2" },
> > +       { .compatible = "fsl,etsec2", .data = (ulong)&etsec2_data },
> > +       { .compatible = "gianfar", .data = (ulong)&gianfar_data },
> >         { }
> >  };
> >
> > diff --git a/include/tsec.h b/include/tsec.h index
> > b17fa957df..047dd3c373 100644
> > --- a/include/tsec.h
> > +++ b/include/tsec.h
> > @@ -394,6 +394,10 @@ struct tsec {
> >
> >  #define TX_BUF_CNT     2
> >
> > +struct tsec_data {
> > +       u32 mdio_regs_off;
> > +};
> > +
> >  struct tsec_private {
> >         struct txbd8 __iomem txbd[TX_BUF_CNT];
> >         struct rxbd8 __iomem rxbd[PKTBUFSRX];
> > --
> > 2.25.1
> >
diff mbox series

Patch

diff --git a/doc/device-tree-bindings/net/fsl-tsec-phy.txt b/doc/device-tree-bindings/net/fsl-tsec-phy.txt
index 8e8574bc97..a44c5fd9d9 100644
--- a/doc/device-tree-bindings/net/fsl-tsec-phy.txt
+++ b/doc/device-tree-bindings/net/fsl-tsec-phy.txt
@@ -2,7 +2,7 @@ 
 
 Properties:
 
-  - compatible : Should be "fsl,etsec2"
+  - compatible : Should be "fsl,etsec2" or "gianfar"
   - reg : Offset and length of the register set for the device
   - phy-handle : See ethernet.txt file in the same directory.
   - phy-connection-type : See ethernet.txt file in the same directory. This
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index cb3e56d439..22658506b2 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -806,11 +806,14 @@  int tsec_probe(struct udevice *dev)
 	struct tsec_private *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args phandle_args;
 	u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
+	struct tsec_data *data;
 	const char *phy_mode;
 	fdt_addr_t reg;
 	ofnode parent;
 	int ret;
 
+	data = (struct tsec_data *)dev_get_driver_data(dev);
+
 	pdata->iobase = (phys_addr_t)dev_read_addr(dev);
 	priv->regs = dev_remap_addr(dev);
 
@@ -831,7 +834,7 @@  int tsec_probe(struct udevice *dev)
 			return -ENOENT;
 		}
 
-		priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET,
+		priv->phyregs_sgmii = map_physmem(reg + data->mdio_regs_off,
 						  0, MAP_NOCACHE);
 	}
 
@@ -883,8 +886,17 @@  static const struct eth_ops tsec_ops = {
 	.mcast = tsec_mcast_addr,
 };
 
+static struct tsec_data etsec2_data = {
+	.mdio_regs_off = TSEC_MDIO_REGS_OFFSET,
+};
+
+static struct tsec_data gianfar_data = {
+	.mdio_regs_off = 0x0,
+};
+
 static const struct udevice_id tsec_ids[] = {
-	{ .compatible = "fsl,etsec2" },
+	{ .compatible = "fsl,etsec2", .data = (ulong)&etsec2_data },
+	{ .compatible = "gianfar", .data = (ulong)&gianfar_data },
 	{ }
 };
 
diff --git a/include/tsec.h b/include/tsec.h
index b17fa957df..047dd3c373 100644
--- a/include/tsec.h
+++ b/include/tsec.h
@@ -394,6 +394,10 @@  struct tsec {
 
 #define TX_BUF_CNT	2
 
+struct tsec_data {
+	u32 mdio_regs_off;
+};
+
 struct tsec_private {
 	struct txbd8 __iomem txbd[TX_BUF_CNT];
 	struct rxbd8 __iomem rxbd[PKTBUFSRX];