Re: [PATCH v2 2/5] net: sun8i-emac: Add a flag for RMII support

2023-02-03 Thread Ramon Fried
On Mon, Jan 23, 2023 at 7:23 PM Andre Przywara  wrote:
>
> On 22/01/2023 22:51, Samuel Holland wrote:
> > Describe this feature instead of using the SoC ID.
>
> Looks alright, also compared against the kernel driver.
>
> > Signed-off-by: Samuel Holland 
>
> Reviewed-by: Andre Przywara 
>
> Cheers,
> Andre
>
> > ---
> >
> > Changes in v2:
> >   - New patch for v2
> >
> >   drivers/net/sun8i_emac.c | 15 +++
> >   1 file changed, 7 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
> > index 986e565cd8..f232b8f087 100644
> > --- a/drivers/net/sun8i_emac.c
> > +++ b/drivers/net/sun8i_emac.c
> > @@ -137,6 +137,7 @@ enum emac_variant_id {
> >
> >   struct emac_variant {
> >   enum emac_variant_idvariant;
> > + boolsupport_rmii;
> >   };
> >
> >   struct emac_dma_desc {
> > @@ -337,9 +338,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata 
> > *pdata,
> >   reg = sun8i_emac_set_syscon_ephy(priv, reg);
> >
> >   reg &= ~(SC_ETCS_MASK | SC_EPIT);
> > - if (priv->variant->variant == H3_EMAC ||
> > - priv->variant->variant == A64_EMAC ||
> > - priv->variant->variant == H6_EMAC)
> > + if (priv->variant->support_rmii)
> >   reg &= ~SC_RMII_EN;
> >
> >   switch (priv->interface) {
> > @@ -353,13 +352,10 @@ static int sun8i_emac_set_syscon(struct 
> > sun8i_eth_pdata *pdata,
> >   reg |= SC_EPIT | SC_ETCS_INT_GMII;
> >   break;
> >   case PHY_INTERFACE_MODE_RMII:
> > - if (priv->variant->variant == H3_EMAC ||
> > - priv->variant->variant == A64_EMAC ||
> > - priv->variant->variant == H6_EMAC) {
> > + if (priv->variant->support_rmii) {
> >   reg |= SC_RMII_EN | SC_ETCS_EXT_GMII;
> > - break;
> > + break;
> >   }
> > - /* RMII not supported on A83T */
> >   default:
> >   debug("%s: Invalid PHY interface\n", __func__);
> >   return -EINVAL;
> > @@ -910,6 +906,7 @@ static const struct emac_variant emac_variant_a83t = {
> >
> >   static const struct emac_variant emac_variant_h3 = {
> >   .variant= H3_EMAC,
> > + .support_rmii   = true,
> >   };
> >
> >   static const struct emac_variant emac_variant_r40 = {
> > @@ -918,10 +915,12 @@ static const struct emac_variant emac_variant_r40 = {
> >
> >   static const struct emac_variant emac_variant_a64 = {
> >   .variant= A64_EMAC,
> > + .support_rmii   = true,
> >   };
> >
> >   static const struct emac_variant emac_variant_h6 = {
> >   .variant= H6_EMAC,
> > + .support_rmii   = true,
> >   };
> >
> >   static const struct udevice_id sun8i_emac_eth_ids[] = {
>
Reviewed-by: Ramon Fried 


Re: [PATCH v2 2/5] net: sun8i-emac: Add a flag for RMII support

2023-01-23 Thread Andre Przywara

On 22/01/2023 22:51, Samuel Holland wrote:

Describe this feature instead of using the SoC ID.


Looks alright, also compared against the kernel driver.


Signed-off-by: Samuel Holland 


Reviewed-by: Andre Przywara 

Cheers,
Andre


---

Changes in v2:
  - New patch for v2

  drivers/net/sun8i_emac.c | 15 +++
  1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 986e565cd8..f232b8f087 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -137,6 +137,7 @@ enum emac_variant_id {
  
  struct emac_variant {

enum emac_variant_idvariant;
+   boolsupport_rmii;
  };
  
  struct emac_dma_desc {

@@ -337,9 +338,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata 
*pdata,
reg = sun8i_emac_set_syscon_ephy(priv, reg);
  
  	reg &= ~(SC_ETCS_MASK | SC_EPIT);

-   if (priv->variant->variant == H3_EMAC ||
-   priv->variant->variant == A64_EMAC ||
-   priv->variant->variant == H6_EMAC)
+   if (priv->variant->support_rmii)
reg &= ~SC_RMII_EN;
  
  	switch (priv->interface) {

@@ -353,13 +352,10 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata 
*pdata,
reg |= SC_EPIT | SC_ETCS_INT_GMII;
break;
case PHY_INTERFACE_MODE_RMII:
-   if (priv->variant->variant == H3_EMAC ||
-   priv->variant->variant == A64_EMAC ||
-   priv->variant->variant == H6_EMAC) {
+   if (priv->variant->support_rmii) {
reg |= SC_RMII_EN | SC_ETCS_EXT_GMII;
-   break;
+   break;
}
-   /* RMII not supported on A83T */
default:
debug("%s: Invalid PHY interface\n", __func__);
return -EINVAL;
@@ -910,6 +906,7 @@ static const struct emac_variant emac_variant_a83t = {
  
  static const struct emac_variant emac_variant_h3 = {

.variant= H3_EMAC,
+   .support_rmii   = true,
  };
  
  static const struct emac_variant emac_variant_r40 = {

@@ -918,10 +915,12 @@ static const struct emac_variant emac_variant_r40 = {
  
  static const struct emac_variant emac_variant_a64 = {

.variant= A64_EMAC,
+   .support_rmii   = true,
  };
  
  static const struct emac_variant emac_variant_h6 = {

.variant= H6_EMAC,
+   .support_rmii   = true,
  };
  
  static const struct udevice_id sun8i_emac_eth_ids[] = {




[PATCH v2 2/5] net: sun8i-emac: Add a flag for RMII support

2023-01-22 Thread Samuel Holland
Describe this feature instead of using the SoC ID.

Signed-off-by: Samuel Holland 
---

Changes in v2:
 - New patch for v2

 drivers/net/sun8i_emac.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 986e565cd8..f232b8f087 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -137,6 +137,7 @@ enum emac_variant_id {
 
 struct emac_variant {
enum emac_variant_idvariant;
+   boolsupport_rmii;
 };
 
 struct emac_dma_desc {
@@ -337,9 +338,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata 
*pdata,
reg = sun8i_emac_set_syscon_ephy(priv, reg);
 
reg &= ~(SC_ETCS_MASK | SC_EPIT);
-   if (priv->variant->variant == H3_EMAC ||
-   priv->variant->variant == A64_EMAC ||
-   priv->variant->variant == H6_EMAC)
+   if (priv->variant->support_rmii)
reg &= ~SC_RMII_EN;
 
switch (priv->interface) {
@@ -353,13 +352,10 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata 
*pdata,
reg |= SC_EPIT | SC_ETCS_INT_GMII;
break;
case PHY_INTERFACE_MODE_RMII:
-   if (priv->variant->variant == H3_EMAC ||
-   priv->variant->variant == A64_EMAC ||
-   priv->variant->variant == H6_EMAC) {
+   if (priv->variant->support_rmii) {
reg |= SC_RMII_EN | SC_ETCS_EXT_GMII;
-   break;
+   break;
}
-   /* RMII not supported on A83T */
default:
debug("%s: Invalid PHY interface\n", __func__);
return -EINVAL;
@@ -910,6 +906,7 @@ static const struct emac_variant emac_variant_a83t = {
 
 static const struct emac_variant emac_variant_h3 = {
.variant= H3_EMAC,
+   .support_rmii   = true,
 };
 
 static const struct emac_variant emac_variant_r40 = {
@@ -918,10 +915,12 @@ static const struct emac_variant emac_variant_r40 = {
 
 static const struct emac_variant emac_variant_a64 = {
.variant= A64_EMAC,
+   .support_rmii   = true,
 };
 
 static const struct emac_variant emac_variant_h6 = {
.variant= H6_EMAC,
+   .support_rmii   = true,
 };
 
 static const struct udevice_id sun8i_emac_eth_ids[] = {
-- 
2.37.4