public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
@ 2022-02-25 18:29 Adam Ford
  2022-02-25 18:29 ` [PATCH V2 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY Adam Ford
  2022-02-25 20:08 ` [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Marek Vasut
  0 siblings, 2 replies; 6+ messages in thread
From: Adam Ford @ 2022-02-25 18:29 UTC (permalink / raw)
  To: u-boot; +Cc: marex, aford, cstevens, Adam Ford, Joe Hershberger, Ramon Fried

Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  Add boolean for explit delays which skips the rgmii mode check
     if explicit delays are set.  This more closely matches the
     behavior in Linux.  Also add the same comments for the delays
     to match the comments found in Linux.

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 1d1118c341..7bc8c84aaa 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -52,6 +52,7 @@
 #define CSR_OPS			0x0000000F
 #define CSR_OPS_CONFIG		BIT(1)
 
+#define APSR_RDM		BIT(13)
 #define APSR_TDM		BIT(14)
 
 #define TCCR_TSRQ0		BIT(0)
@@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
 	struct ravb_priv *eth = dev_get_priv(dev);
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	int ret = 0;
+	int mode = 0;
+	unsigned int delay;
+	bool explicit_delay = false;
 
 	/* Set CONFIG mode */
 	ret = ravb_reset(dev);
@@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
 	    (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
 		return 0;
 
-	if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
-	    (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
-		writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
+	if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) {
+		/* Valid values are 0 and 2000, according to DT bindings */
+		if (delay) {
+			mode |= APSR_TDM;
+			explicit_delay = true;
+		}
+	}
+
+	if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) {
+		/* Valid values are 0 and 1800, according to DT bindings */
+		if (delay) {
+			mode |= APSR_RDM;
+			explicit_delay = true;
+		}
+	}
+
+	if (!explicit_delay) {
+		if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+		    pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID)
+			mode |= APSR_RDM;
+
+		if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+		    pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
+			mode |= APSR_TDM;
+	}
+
+	writel(mode, eth->iobase + RAVB_REG_APSR);
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH V2 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY
  2022-02-25 18:29 [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Adam Ford
@ 2022-02-25 18:29 ` Adam Ford
  2022-02-25 20:08 ` [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Marek Vasut
  1 sibling, 0 replies; 6+ messages in thread
From: Adam Ford @ 2022-02-25 18:29 UTC (permalink / raw)
  To: u-boot; +Cc: marex, aford, cstevens, Adam Ford, Joe Hershberger, Ramon Fried

The wrong phy was being enabled, because it worked and the proper
PHY did not.  After the Renesas maintainer made some adjustments
to the device tree, Linux was able to use the proper driver, and
when that device tree was ported to Linux, the ethernet stopped
working due to the lack of rgmii-rxid support.  Now that
rgmii-rxid is supported, enable the proper driver to restore
ethernet function.

Fixes: 1eaf61c84db6 ("arm: dts: beacon-rzg2: Resync device trees with Linux 5.16-rc3")
Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  No change

diff --git a/configs/rzg2_beacon_defconfig b/configs/rzg2_beacon_defconfig
index e6a0d68962..91b3fa2948 100644
--- a/configs/rzg2_beacon_defconfig
+++ b/configs/rzg2_beacon_defconfig
@@ -62,7 +62,7 @@ CONFIG_DM_MTD=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_BITBANGMII=y
-CONFIG_PHY_REALTEK=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_DM_ETH=y
 CONFIG_RENESAS_RAVB=y
 CONFIG_DM_REGULATOR=y
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
  2022-02-25 18:29 [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Adam Ford
  2022-02-25 18:29 ` [PATCH V2 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY Adam Ford
@ 2022-02-25 20:08 ` Marek Vasut
  2022-02-25 20:10   ` Adam Ford
  1 sibling, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2022-02-25 20:08 UTC (permalink / raw)
  To: Adam Ford, u-boot; +Cc: aford, cstevens, Joe Hershberger, Ramon Fried

On 2/25/22 19:29, Adam Ford wrote:
> Some boards like the Beacon RZ/G2 SOM use either flags for
> tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.
> 
> In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
> is set or the mode is rgmii-rxid, and the APSR_TDM is set when
> tx-internal-delay-ps is found or rgmii-txid is set, and both
> are set if rgmii-id is set.
> 
> The ravb driver in U-Boot driver was missing rgmii-rxid support,
> so add that support in a similar fashion to what is done in Linux.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> ---
> V2:  Add boolean for explit delays which skips the rgmii mode check
>       if explicit delays are set.  This more closely matches the
>       behavior in Linux.  Also add the same comments for the delays
>       to match the comments found in Linux.
> 
> diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> index 1d1118c341..7bc8c84aaa 100644
> --- a/drivers/net/ravb.c
> +++ b/drivers/net/ravb.c
> @@ -52,6 +52,7 @@
>   #define CSR_OPS			0x0000000F
>   #define CSR_OPS_CONFIG		BIT(1)
>   
> +#define APSR_RDM		BIT(13)
>   #define APSR_TDM		BIT(14)
>   
>   #define TCCR_TSRQ0		BIT(0)
> @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
>   	struct ravb_priv *eth = dev_get_priv(dev);
>   	struct eth_pdata *pdata = dev_get_plat(dev);
>   	int ret = 0;
> +	int mode = 0;
> +	unsigned int delay;
> +	bool explicit_delay = false;
>   
>   	/* Set CONFIG mode */
>   	ret = ravb_reset(dev);
> @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
>   	    (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
>   		return 0;
>   
> -	if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
> -	    (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
> -		writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
> +	if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) {
> +		/* Valid values are 0 and 2000, according to DT bindings */
> +		if (delay) {
> +			mode |= APSR_TDM;
> +			explicit_delay = true;
> +		}
> +	}
> +
> +	if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) {
> +		/* Valid values are 0 and 1800, according to DT bindings */
> +		if (delay) {
> +			mode |= APSR_RDM;
> +			explicit_delay = true;
> +		}
> +	}

Any reason to reverse those two tests compared to Linux ?
Linux does rx test before tx test, and keeps the tests sorted 
alphabetically.

[...]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
  2022-02-25 20:08 ` [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Marek Vasut
@ 2022-02-25 20:10   ` Adam Ford
  2022-02-25 20:43     ` Marek Vasut
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Ford @ 2022-02-25 20:10 UTC (permalink / raw)
  To: Marek Vasut
  Cc: U-Boot Mailing List, Adam Ford-BE, cstevens, Joe Hershberger,
	Ramon Fried

On Fri, Feb 25, 2022 at 2:08 PM Marek Vasut <marex@denx.de> wrote:
>
> On 2/25/22 19:29, Adam Ford wrote:
> > Some boards like the Beacon RZ/G2 SOM use either flags for
> > tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.
> >
> > In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
> > is set or the mode is rgmii-rxid, and the APSR_TDM is set when
> > tx-internal-delay-ps is found or rgmii-txid is set, and both
> > are set if rgmii-id is set.
> >
> > The ravb driver in U-Boot driver was missing rgmii-rxid support,
> > so add that support in a similar fashion to what is done in Linux.
> >
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> > ---
> > V2:  Add boolean for explit delays which skips the rgmii mode check
> >       if explicit delays are set.  This more closely matches the
> >       behavior in Linux.  Also add the same comments for the delays
> >       to match the comments found in Linux.
> >
> > diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> > index 1d1118c341..7bc8c84aaa 100644
> > --- a/drivers/net/ravb.c
> > +++ b/drivers/net/ravb.c
> > @@ -52,6 +52,7 @@
> >   #define CSR_OPS                     0x0000000F
> >   #define CSR_OPS_CONFIG              BIT(1)
> >
> > +#define APSR_RDM             BIT(13)
> >   #define APSR_TDM            BIT(14)
> >
> >   #define TCCR_TSRQ0          BIT(0)
> > @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
> >       struct ravb_priv *eth = dev_get_priv(dev);
> >       struct eth_pdata *pdata = dev_get_plat(dev);
> >       int ret = 0;
> > +     int mode = 0;
> > +     unsigned int delay;
> > +     bool explicit_delay = false;
> >
> >       /* Set CONFIG mode */
> >       ret = ravb_reset(dev);
> > @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
> >           (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
> >               return 0;
> >
> > -     if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
> > -         (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
> > -             writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
> > +     if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) {
> > +             /* Valid values are 0 and 2000, according to DT bindings */
> > +             if (delay) {
> > +                     mode |= APSR_TDM;
> > +                     explicit_delay = true;
> > +             }
> > +     }
> > +
> > +     if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) {
> > +             /* Valid values are 0 and 1800, according to DT bindings */
> > +             if (delay) {
> > +                     mode |= APSR_RDM;
> > +                     explicit_delay = true;
> > +             }
> > +     }
>
> Any reason to reverse those two tests compared to Linux ?
> Linux does rx test before tx test, and keeps the tests sorted
> alphabetically.

It wasn't intentional.  I can swap them.

adam
>
> [...]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
  2022-02-25 20:10   ` Adam Ford
@ 2022-02-25 20:43     ` Marek Vasut
  2022-02-25 21:56       ` Adam Ford
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2022-02-25 20:43 UTC (permalink / raw)
  To: Adam Ford
  Cc: U-Boot Mailing List, Adam Ford-BE, cstevens, Joe Hershberger,
	Ramon Fried

On 2/25/22 21:10, Adam Ford wrote:
> On Fri, Feb 25, 2022 at 2:08 PM Marek Vasut <marex@denx.de> wrote:
>>
>> On 2/25/22 19:29, Adam Ford wrote:
>>> Some boards like the Beacon RZ/G2 SOM use either flags for
>>> tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.
>>>
>>> In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
>>> is set or the mode is rgmii-rxid, and the APSR_TDM is set when
>>> tx-internal-delay-ps is found or rgmii-txid is set, and both
>>> are set if rgmii-id is set.
>>>
>>> The ravb driver in U-Boot driver was missing rgmii-rxid support,
>>> so add that support in a similar fashion to what is done in Linux.
>>>
>>> Signed-off-by: Adam Ford <aford173@gmail.com>
>>> ---
>>> V2:  Add boolean for explit delays which skips the rgmii mode check
>>>        if explicit delays are set.  This more closely matches the
>>>        behavior in Linux.  Also add the same comments for the delays
>>>        to match the comments found in Linux.
>>>
>>> diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
>>> index 1d1118c341..7bc8c84aaa 100644
>>> --- a/drivers/net/ravb.c
>>> +++ b/drivers/net/ravb.c
>>> @@ -52,6 +52,7 @@
>>>    #define CSR_OPS                     0x0000000F
>>>    #define CSR_OPS_CONFIG              BIT(1)
>>>
>>> +#define APSR_RDM             BIT(13)
>>>    #define APSR_TDM            BIT(14)
>>>
>>>    #define TCCR_TSRQ0          BIT(0)
>>> @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
>>>        struct ravb_priv *eth = dev_get_priv(dev);
>>>        struct eth_pdata *pdata = dev_get_plat(dev);
>>>        int ret = 0;
>>> +     int mode = 0;
>>> +     unsigned int delay;
>>> +     bool explicit_delay = false;
>>>
>>>        /* Set CONFIG mode */
>>>        ret = ravb_reset(dev);
>>> @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
>>>            (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
>>>                return 0;
>>>
>>> -     if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
>>> -         (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
>>> -             writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
>>> +     if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) {
>>> +             /* Valid values are 0 and 2000, according to DT bindings */
>>> +             if (delay) {
>>> +                     mode |= APSR_TDM;
>>> +                     explicit_delay = true;
>>> +             }
>>> +     }
>>> +
>>> +     if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) {
>>> +             /* Valid values are 0 and 1800, according to DT bindings */
>>> +             if (delay) {
>>> +                     mode |= APSR_RDM;
>>> +                     explicit_delay = true;
>>> +             }
>>> +     }
>>
>> Any reason to reverse those two tests compared to Linux ?
>> Linux does rx test before tx test, and keeps the tests sorted
>> alphabetically.
> 
> It wasn't intentional.  I can swap them.

V3 is now applied and in CI.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
  2022-02-25 20:43     ` Marek Vasut
@ 2022-02-25 21:56       ` Adam Ford
  0 siblings, 0 replies; 6+ messages in thread
From: Adam Ford @ 2022-02-25 21:56 UTC (permalink / raw)
  To: Marek Vasut
  Cc: U-Boot Mailing List, Adam Ford-BE, cstevens, Joe Hershberger,
	Ramon Fried

On Fri, Feb 25, 2022 at 2:43 PM Marek Vasut <marex@denx.de> wrote:
>
> On 2/25/22 21:10, Adam Ford wrote:
> > On Fri, Feb 25, 2022 at 2:08 PM Marek Vasut <marex@denx.de> wrote:
> >>
> >> On 2/25/22 19:29, Adam Ford wrote:
> >>> Some boards like the Beacon RZ/G2 SOM use either flags for
> >>> tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.
> >>>
> >>> In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
> >>> is set or the mode is rgmii-rxid, and the APSR_TDM is set when
> >>> tx-internal-delay-ps is found or rgmii-txid is set, and both
> >>> are set if rgmii-id is set.
> >>>
> >>> The ravb driver in U-Boot driver was missing rgmii-rxid support,
> >>> so add that support in a similar fashion to what is done in Linux.
> >>>
> >>> Signed-off-by: Adam Ford <aford173@gmail.com>
> >>> ---
> >>> V2:  Add boolean for explit delays which skips the rgmii mode check
> >>>        if explicit delays are set.  This more closely matches the
> >>>        behavior in Linux.  Also add the same comments for the delays
> >>>        to match the comments found in Linux.
> >>>
> >>> diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> >>> index 1d1118c341..7bc8c84aaa 100644
> >>> --- a/drivers/net/ravb.c
> >>> +++ b/drivers/net/ravb.c
> >>> @@ -52,6 +52,7 @@
> >>>    #define CSR_OPS                     0x0000000F
> >>>    #define CSR_OPS_CONFIG              BIT(1)
> >>>
> >>> +#define APSR_RDM             BIT(13)
> >>>    #define APSR_TDM            BIT(14)
> >>>
> >>>    #define TCCR_TSRQ0          BIT(0)
> >>> @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev)
> >>>        struct ravb_priv *eth = dev_get_priv(dev);
> >>>        struct eth_pdata *pdata = dev_get_plat(dev);
> >>>        int ret = 0;
> >>> +     int mode = 0;
> >>> +     unsigned int delay;
> >>> +     bool explicit_delay = false;
> >>>
> >>>        /* Set CONFIG mode */
> >>>        ret = ravb_reset(dev);
> >>> @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev)
> >>>            (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
> >>>                return 0;
> >>>
> >>> -     if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
> >>> -         (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
> >>> -             writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
> >>> +     if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) {
> >>> +             /* Valid values are 0 and 2000, according to DT bindings */
> >>> +             if (delay) {
> >>> +                     mode |= APSR_TDM;
> >>> +                     explicit_delay = true;
> >>> +             }
> >>> +     }
> >>> +
> >>> +     if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) {
> >>> +             /* Valid values are 0 and 1800, according to DT bindings */
> >>> +             if (delay) {
> >>> +                     mode |= APSR_RDM;
> >>> +                     explicit_delay = true;
> >>> +             }
> >>> +     }
> >>
> >> Any reason to reverse those two tests compared to Linux ?
> >> Linux does rx test before tx test, and keeps the tests sorted
> >> alphabetically.
> >
> > It wasn't intentional.  I can swap them.
>
> V3 is now applied and in CI.

Thank you!

Just as an FYI, you are not showing up as a maintainer for the ravb
driver when run check_maintainer.py.  I knew to add you to the CC
list, but others in the future may not know to do that.

adam

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-25 21:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-25 18:29 [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Adam Ford
2022-02-25 18:29 ` [PATCH V2 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY Adam Ford
2022-02-25 20:08 ` [PATCH V2 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Marek Vasut
2022-02-25 20:10   ` Adam Ford
2022-02-25 20:43     ` Marek Vasut
2022-02-25 21:56       ` Adam Ford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox