netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] net: phy: at803x: add ar9331 support
@ 2019-10-01  6:08 Oleksij Rempel
  2019-10-01  6:08 ` [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs Oleksij Rempel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Oleksij Rempel @ 2019-10-01  6:08 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: Oleksij Rempel, Pengutronix Kernel Team, David S. Miller, netdev,
	linux-kernel

changes v2:
- use PHY_ID_MATCH_EXACT instead of leaky masking
- remove probe and struct at803x_priv

Oleksij Rempel (3):
  net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs
  net: phy: at803x: add ar9331 support
  net: phy: at803x: remove probe and struct at803x_priv

 drivers/net/phy/at803x.c | 45 ++++++++++++++--------------------------
 1 file changed, 15 insertions(+), 30 deletions(-)

-- 
2.23.0


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

* [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs
  2019-10-01  6:08 [PATCH v2 0/3] net: phy: at803x: add ar9331 support Oleksij Rempel
@ 2019-10-01  6:08 ` Oleksij Rempel
  2019-10-01 18:37   ` Heiner Kallweit
  2019-10-01  6:08 ` [PATCH v2 2/3] net: phy: at803x: add ar9331 support Oleksij Rempel
  2019-10-01  6:08 ` [PATCH v2 3/3] net: phy: at803x: remove probe and struct at803x_priv Oleksij Rempel
  2 siblings, 1 reply; 7+ messages in thread
From: Oleksij Rempel @ 2019-10-01  6:08 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: Oleksij Rempel, Pengutronix Kernel Team, David S. Miller, netdev,
	linux-kernel

Use exact match for all IDs. We have no sanity checks, so we can peek
a device with no exact ID and different register layout.

Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/at803x.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 6ad8b1c63c34..7895dbe600ac 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -364,9 +364,8 @@ static int at803x_aneg_done(struct phy_device *phydev)
 static struct phy_driver at803x_driver[] = {
 {
 	/* ATHEROS 8035 */
-	.phy_id			= ATH8035_PHY_ID,
+	PHY_ID_MATCH_EXACT(ATH8035_PHY_ID),
 	.name			= "Atheros 8035 ethernet",
-	.phy_id_mask		= AT803X_PHY_ID_MASK,
 	.probe			= at803x_probe,
 	.config_init		= at803x_config_init,
 	.set_wol		= at803x_set_wol,
@@ -378,9 +377,8 @@ static struct phy_driver at803x_driver[] = {
 	.config_intr		= at803x_config_intr,
 }, {
 	/* ATHEROS 8030 */
-	.phy_id			= ATH8030_PHY_ID,
+	PHY_ID_MATCH_EXACT(ATH8030_PHY_ID),
 	.name			= "Atheros 8030 ethernet",
-	.phy_id_mask		= AT803X_PHY_ID_MASK,
 	.probe			= at803x_probe,
 	.config_init		= at803x_config_init,
 	.link_change_notify	= at803x_link_change_notify,
@@ -393,9 +391,8 @@ static struct phy_driver at803x_driver[] = {
 	.config_intr		= at803x_config_intr,
 }, {
 	/* ATHEROS 8031 */
-	.phy_id			= ATH8031_PHY_ID,
+	PHY_ID_MATCH_EXACT(ATH8031_PHY_ID),
 	.name			= "Atheros 8031 ethernet",
-	.phy_id_mask		= AT803X_PHY_ID_MASK,
 	.probe			= at803x_probe,
 	.config_init		= at803x_config_init,
 	.set_wol		= at803x_set_wol,
@@ -411,9 +408,7 @@ static struct phy_driver at803x_driver[] = {
 module_phy_driver(at803x_driver);
 
 static struct mdio_device_id __maybe_unused atheros_tbl[] = {
-	{ ATH8030_PHY_ID, AT803X_PHY_ID_MASK },
-	{ ATH8031_PHY_ID, AT803X_PHY_ID_MASK },
-	{ ATH8035_PHY_ID, AT803X_PHY_ID_MASK },
+	{ PHY_ID_MATCH_VENDOR(ATH8030_PHY_ID) },
 	{ }
 };
 
-- 
2.23.0


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

* [PATCH v2 2/3] net: phy: at803x: add ar9331 support
  2019-10-01  6:08 [PATCH v2 0/3] net: phy: at803x: add ar9331 support Oleksij Rempel
  2019-10-01  6:08 ` [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs Oleksij Rempel
@ 2019-10-01  6:08 ` Oleksij Rempel
  2019-10-01 18:40   ` Heiner Kallweit
  2019-10-01  6:08 ` [PATCH v2 3/3] net: phy: at803x: remove probe and struct at803x_priv Oleksij Rempel
  2 siblings, 1 reply; 7+ messages in thread
From: Oleksij Rempel @ 2019-10-01  6:08 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: Oleksij Rempel, Pengutronix Kernel Team, David S. Miller, netdev,
	linux-kernel

Mostly this hardware can work with generic PHY driver, but this change
is needed to provided interrupt handling support.
Tested with dsa ar9331-switch driver.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/at803x.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 7895dbe600ac..42492f83c8d7 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -53,6 +53,7 @@
 #define AT803X_DEBUG_REG_5			0x05
 #define AT803X_DEBUG_TX_CLK_DLY_EN		BIT(8)
 
+#define ATH9331_PHY_ID 0x004dd041
 #define ATH8030_PHY_ID 0x004dd076
 #define ATH8031_PHY_ID 0x004dd074
 #define ATH8035_PHY_ID 0x004dd072
@@ -403,6 +404,16 @@ static struct phy_driver at803x_driver[] = {
 	.aneg_done		= at803x_aneg_done,
 	.ack_interrupt		= &at803x_ack_interrupt,
 	.config_intr		= &at803x_config_intr,
+}, {
+	/* ATHEROS AR9331 */
+	PHY_ID_MATCH_EXACT(ATH9331_PHY_ID),
+	.name			= "Atheros AR9331 built-in PHY",
+	.config_init		= at803x_config_init,
+	.suspend		= at803x_suspend,
+	.resume			= at803x_resume,
+	/* PHY_BASIC_FEATURES */
+	.ack_interrupt		= &at803x_ack_interrupt,
+	.config_intr		= &at803x_config_intr,
 } };
 
 module_phy_driver(at803x_driver);
-- 
2.23.0


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

* [PATCH v2 3/3] net: phy: at803x: remove probe and struct at803x_priv
  2019-10-01  6:08 [PATCH v2 0/3] net: phy: at803x: add ar9331 support Oleksij Rempel
  2019-10-01  6:08 ` [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs Oleksij Rempel
  2019-10-01  6:08 ` [PATCH v2 2/3] net: phy: at803x: add ar9331 support Oleksij Rempel
@ 2019-10-01  6:08 ` Oleksij Rempel
  2019-10-01 18:40   ` Heiner Kallweit
  2 siblings, 1 reply; 7+ messages in thread
From: Oleksij Rempel @ 2019-10-01  6:08 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: Oleksij Rempel, Pengutronix Kernel Team, David S. Miller, netdev,
	linux-kernel

struct at803x_priv is never used in this driver. So remove it
and the probe function allocating it.

Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/at803x.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 42492f83c8d7..e64f77e152f4 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -63,10 +63,6 @@ MODULE_DESCRIPTION("Atheros 803x PHY driver");
 MODULE_AUTHOR("Matus Ujhelyi");
 MODULE_LICENSE("GPL");
 
-struct at803x_priv {
-	bool phy_reset:1;
-};
-
 struct at803x_context {
 	u16 bmcr;
 	u16 advertise;
@@ -232,20 +228,6 @@ static int at803x_resume(struct phy_device *phydev)
 	return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0);
 }
 
-static int at803x_probe(struct phy_device *phydev)
-{
-	struct device *dev = &phydev->mdio.dev;
-	struct at803x_priv *priv;
-
-	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	phydev->priv = priv;
-
-	return 0;
-}
-
 static int at803x_config_init(struct phy_device *phydev)
 {
 	int ret;
@@ -367,7 +349,6 @@ static struct phy_driver at803x_driver[] = {
 	/* ATHEROS 8035 */
 	PHY_ID_MATCH_EXACT(ATH8035_PHY_ID),
 	.name			= "Atheros 8035 ethernet",
-	.probe			= at803x_probe,
 	.config_init		= at803x_config_init,
 	.set_wol		= at803x_set_wol,
 	.get_wol		= at803x_get_wol,
@@ -380,7 +361,6 @@ static struct phy_driver at803x_driver[] = {
 	/* ATHEROS 8030 */
 	PHY_ID_MATCH_EXACT(ATH8030_PHY_ID),
 	.name			= "Atheros 8030 ethernet",
-	.probe			= at803x_probe,
 	.config_init		= at803x_config_init,
 	.link_change_notify	= at803x_link_change_notify,
 	.set_wol		= at803x_set_wol,
@@ -394,7 +374,6 @@ static struct phy_driver at803x_driver[] = {
 	/* ATHEROS 8031 */
 	PHY_ID_MATCH_EXACT(ATH8031_PHY_ID),
 	.name			= "Atheros 8031 ethernet",
-	.probe			= at803x_probe,
 	.config_init		= at803x_config_init,
 	.set_wol		= at803x_set_wol,
 	.get_wol		= at803x_get_wol,
-- 
2.23.0


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

* Re: [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs
  2019-10-01  6:08 ` [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs Oleksij Rempel
@ 2019-10-01 18:37   ` Heiner Kallweit
  0 siblings, 0 replies; 7+ messages in thread
From: Heiner Kallweit @ 2019-10-01 18:37 UTC (permalink / raw)
  To: Oleksij Rempel, Andrew Lunn, Florian Fainelli
  Cc: Pengutronix Kernel Team, David S. Miller, netdev, linux-kernel

On 01.10.2019 08:08, Oleksij Rempel wrote:
> Use exact match for all IDs. We have no sanity checks, so we can peek
> a device with no exact ID and different register layout.
> 

I think it would be better to use PHY_ID_MATCH_EXACT for the newly
added AR9331 only. The mask 0xffffffef for the other Atheros PHY's
may be there for a reason. In this case other PHY's matching the
mask would be silently switched to the genphy driver and may
misbehave.

> Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/phy/at803x.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 6ad8b1c63c34..7895dbe600ac 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -364,9 +364,8 @@ static int at803x_aneg_done(struct phy_device *phydev)
>  static struct phy_driver at803x_driver[] = {
>  {
>  	/* ATHEROS 8035 */
> -	.phy_id			= ATH8035_PHY_ID,
> +	PHY_ID_MATCH_EXACT(ATH8035_PHY_ID),
>  	.name			= "Atheros 8035 ethernet",
> -	.phy_id_mask		= AT803X_PHY_ID_MASK,
>  	.probe			= at803x_probe,
>  	.config_init		= at803x_config_init,
>  	.set_wol		= at803x_set_wol,
> @@ -378,9 +377,8 @@ static struct phy_driver at803x_driver[] = {
>  	.config_intr		= at803x_config_intr,
>  }, {
>  	/* ATHEROS 8030 */
> -	.phy_id			= ATH8030_PHY_ID,
> +	PHY_ID_MATCH_EXACT(ATH8030_PHY_ID),
>  	.name			= "Atheros 8030 ethernet",
> -	.phy_id_mask		= AT803X_PHY_ID_MASK,
>  	.probe			= at803x_probe,
>  	.config_init		= at803x_config_init,
>  	.link_change_notify	= at803x_link_change_notify,
> @@ -393,9 +391,8 @@ static struct phy_driver at803x_driver[] = {
>  	.config_intr		= at803x_config_intr,
>  }, {
>  	/* ATHEROS 8031 */
> -	.phy_id			= ATH8031_PHY_ID,
> +	PHY_ID_MATCH_EXACT(ATH8031_PHY_ID),
>  	.name			= "Atheros 8031 ethernet",
> -	.phy_id_mask		= AT803X_PHY_ID_MASK,
>  	.probe			= at803x_probe,
>  	.config_init		= at803x_config_init,
>  	.set_wol		= at803x_set_wol,
> @@ -411,9 +408,7 @@ static struct phy_driver at803x_driver[] = {
>  module_phy_driver(at803x_driver);
>  
>  static struct mdio_device_id __maybe_unused atheros_tbl[] = {
> -	{ ATH8030_PHY_ID, AT803X_PHY_ID_MASK },
> -	{ ATH8031_PHY_ID, AT803X_PHY_ID_MASK },
> -	{ ATH8035_PHY_ID, AT803X_PHY_ID_MASK },
> +	{ PHY_ID_MATCH_VENDOR(ATH8030_PHY_ID) },
>  	{ }
>  };
>  
> 


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

* Re: [PATCH v2 2/3] net: phy: at803x: add ar9331 support
  2019-10-01  6:08 ` [PATCH v2 2/3] net: phy: at803x: add ar9331 support Oleksij Rempel
@ 2019-10-01 18:40   ` Heiner Kallweit
  0 siblings, 0 replies; 7+ messages in thread
From: Heiner Kallweit @ 2019-10-01 18:40 UTC (permalink / raw)
  To: Oleksij Rempel, Andrew Lunn, Florian Fainelli
  Cc: Pengutronix Kernel Team, David S. Miller, netdev, linux-kernel

On 01.10.2019 08:08, Oleksij Rempel wrote:
> Mostly this hardware can work with generic PHY driver, but this change
> is needed to provided interrupt handling support.
> Tested with dsa ar9331-switch driver.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/phy/at803x.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 7895dbe600ac..42492f83c8d7 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -53,6 +53,7 @@
>  #define AT803X_DEBUG_REG_5			0x05
>  #define AT803X_DEBUG_TX_CLK_DLY_EN		BIT(8)
>  
> +#define ATH9331_PHY_ID 0x004dd041
>  #define ATH8030_PHY_ID 0x004dd076
>  #define ATH8031_PHY_ID 0x004dd074
>  #define ATH8035_PHY_ID 0x004dd072
> @@ -403,6 +404,16 @@ static struct phy_driver at803x_driver[] = {
>  	.aneg_done		= at803x_aneg_done,
>  	.ack_interrupt		= &at803x_ack_interrupt,
>  	.config_intr		= &at803x_config_intr,
> +}, {
> +	/* ATHEROS AR9331 */
> +	PHY_ID_MATCH_EXACT(ATH9331_PHY_ID),
> +	.name			= "Atheros AR9331 built-in PHY",
> +	.config_init		= at803x_config_init,
> +	.suspend		= at803x_suspend,
> +	.resume			= at803x_resume,
> +	/* PHY_BASIC_FEATURES */
> +	.ack_interrupt		= &at803x_ack_interrupt,
> +	.config_intr		= &at803x_config_intr,
>  } };
>  
>  module_phy_driver(at803x_driver);
> 

Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>

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

* Re: [PATCH v2 3/3] net: phy: at803x: remove probe and struct at803x_priv
  2019-10-01  6:08 ` [PATCH v2 3/3] net: phy: at803x: remove probe and struct at803x_priv Oleksij Rempel
@ 2019-10-01 18:40   ` Heiner Kallweit
  0 siblings, 0 replies; 7+ messages in thread
From: Heiner Kallweit @ 2019-10-01 18:40 UTC (permalink / raw)
  To: Oleksij Rempel, Andrew Lunn, Florian Fainelli
  Cc: Pengutronix Kernel Team, David S. Miller, netdev, linux-kernel

On 01.10.2019 08:08, Oleksij Rempel wrote:
> struct at803x_priv is never used in this driver. So remove it
> and the probe function allocating it.
> 
> Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/phy/at803x.c | 21 ---------------------
>  1 file changed, 21 deletions(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 42492f83c8d7..e64f77e152f4 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -63,10 +63,6 @@ MODULE_DESCRIPTION("Atheros 803x PHY driver");
>  MODULE_AUTHOR("Matus Ujhelyi");
>  MODULE_LICENSE("GPL");
>  
> -struct at803x_priv {
> -	bool phy_reset:1;
> -};
> -
>  struct at803x_context {
>  	u16 bmcr;
>  	u16 advertise;
> @@ -232,20 +228,6 @@ static int at803x_resume(struct phy_device *phydev)
>  	return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0);
>  }
>  
> -static int at803x_probe(struct phy_device *phydev)
> -{
> -	struct device *dev = &phydev->mdio.dev;
> -	struct at803x_priv *priv;
> -
> -	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -
> -	phydev->priv = priv;
> -
> -	return 0;
> -}
> -
>  static int at803x_config_init(struct phy_device *phydev)
>  {
>  	int ret;
> @@ -367,7 +349,6 @@ static struct phy_driver at803x_driver[] = {
>  	/* ATHEROS 8035 */
>  	PHY_ID_MATCH_EXACT(ATH8035_PHY_ID),
>  	.name			= "Atheros 8035 ethernet",
> -	.probe			= at803x_probe,
>  	.config_init		= at803x_config_init,
>  	.set_wol		= at803x_set_wol,
>  	.get_wol		= at803x_get_wol,
> @@ -380,7 +361,6 @@ static struct phy_driver at803x_driver[] = {
>  	/* ATHEROS 8030 */
>  	PHY_ID_MATCH_EXACT(ATH8030_PHY_ID),
>  	.name			= "Atheros 8030 ethernet",
> -	.probe			= at803x_probe,
>  	.config_init		= at803x_config_init,
>  	.link_change_notify	= at803x_link_change_notify,
>  	.set_wol		= at803x_set_wol,
> @@ -394,7 +374,6 @@ static struct phy_driver at803x_driver[] = {
>  	/* ATHEROS 8031 */
>  	PHY_ID_MATCH_EXACT(ATH8031_PHY_ID),
>  	.name			= "Atheros 8031 ethernet",
> -	.probe			= at803x_probe,
>  	.config_init		= at803x_config_init,
>  	.set_wol		= at803x_set_wol,
>  	.get_wol		= at803x_get_wol,
> 

Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>


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

end of thread, other threads:[~2019-10-01 18:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01  6:08 [PATCH v2 0/3] net: phy: at803x: add ar9331 support Oleksij Rempel
2019-10-01  6:08 ` [PATCH v2 1/3] net: phy: at803x: use PHY_ID_MATCH_EXACT for IDs Oleksij Rempel
2019-10-01 18:37   ` Heiner Kallweit
2019-10-01  6:08 ` [PATCH v2 2/3] net: phy: at803x: add ar9331 support Oleksij Rempel
2019-10-01 18:40   ` Heiner Kallweit
2019-10-01  6:08 ` [PATCH v2 3/3] net: phy: at803x: remove probe and struct at803x_priv Oleksij Rempel
2019-10-01 18:40   ` Heiner Kallweit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).