linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] phy/micrel: Add support for KSZ8031
@ 2013-03-11  8:50 Hector Palacios
  2013-03-11  8:50 ` [PATCH 2/2] phy/micrel: move flag handling to function for common use Hector Palacios
  2013-03-11 12:39 ` [PATCH 1/2] phy/micrel: Add support for KSZ8031 Marek Vasut
  0 siblings, 2 replies; 5+ messages in thread
From: Hector Palacios @ 2013-03-11  8:50 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, marex, davem, Hector Palacios

Micrel PHY KSZ8031 is similar to KSZ8021 and also requires the special
initialization of "Operation Mode Strap Override" in reg 0x16
introduced in 212ea99 (phy/micrel: Implement support for KSZ8021).

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
 drivers/net/phy/micrel.c   |   14 ++++++++++++++
 include/linux/micrel_phy.h |    1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index b983596..1ab6743 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -187,6 +187,19 @@ static struct phy_driver ksphy_driver[] = {
 	.config_intr	= kszphy_config_intr,
 	.driver		= { .owner = THIS_MODULE,},
 }, {
+	.phy_id		= PHY_ID_KSZ8031,
+	.phy_id_mask	= 0x00ffffff,
+	.name		= "Micrel KSZ8031",
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause |
+			   SUPPORTED_Asym_Pause),
+	.flags		= PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
+	.config_init	= ksz8021_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.ack_interrupt	= kszphy_ack_interrupt,
+	.config_intr	= kszphy_config_intr,
+	.driver		= { .owner = THIS_MODULE,},
+}, {
 	.phy_id		= PHY_ID_KSZ8041,
 	.phy_id_mask	= 0x00fffff0,
 	.name		= "Micrel KSZ8041",
@@ -273,6 +286,7 @@ static struct mdio_device_id __maybe_unused micrel_tbl[] = {
 	{ PHY_ID_KSZ8001, 0x00ffffff },
 	{ PHY_ID_KS8737, 0x00fffff0 },
 	{ PHY_ID_KSZ8021, 0x00ffffff },
+	{ PHY_ID_KSZ8031, 0x00ffffff },
 	{ PHY_ID_KSZ8041, 0x00fffff0 },
 	{ PHY_ID_KSZ8051, 0x00fffff0 },
 	{ PHY_ID_KSZ8873MLL, 0x00fffff0 },
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index adfe8c0..b1ffaa4 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -19,6 +19,7 @@
 #define PHY_ID_KSZ9021		0x00221610
 #define PHY_ID_KS8737		0x00221720
 #define PHY_ID_KSZ8021		0x00221555
+#define PHY_ID_KSZ8031		0x00221556
 #define PHY_ID_KSZ8041		0x00221510
 #define PHY_ID_KSZ8051		0x00221550
 /* both for ks8001 Rev. A/B, and for ks8721 Rev 3. */
-- 
1.7.9.5


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

* [PATCH 2/2] phy/micrel: move flag handling to function for common use
  2013-03-11  8:50 [PATCH 1/2] phy/micrel: Add support for KSZ8031 Hector Palacios
@ 2013-03-11  8:50 ` Hector Palacios
  2013-03-12 10:55   ` David Miller
  2013-03-11 12:39 ` [PATCH 1/2] phy/micrel: Add support for KSZ8031 Marek Vasut
  1 sibling, 1 reply; 5+ messages in thread
From: Hector Palacios @ 2013-03-11  8:50 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, marex, davem, Hector Palacios

The flag MICREL_PHY_50MHZ_CLK is not of exclusive use of KSZ8051
model. At least KSZ8021 and KSZ8031 models also use it.
This patch moves the handling of this and future flags to a
separate function so that the different PHY models can call it on
their init function, if needed.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
 drivers/net/phy/micrel.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 1ab6743..6a0834b 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -48,6 +48,18 @@
 #define KS8737_CTRL_INT_ACTIVE_HIGH		(1 << 14)
 #define KSZ8051_RMII_50MHZ_CLK			(1 << 7)
 
+static int ksz_config_flags(struct phy_device *phydev)
+{
+	int regval;
+
+	if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
+		regval = phy_read(phydev, MII_KSZPHY_CTRL);
+		regval |= KSZ8051_RMII_50MHZ_CLK;
+		return phy_write(phydev, MII_KSZPHY_CTRL, regval);
+	}
+	return 0;
+}
+
 static int kszphy_ack_interrupt(struct phy_device *phydev)
 {
 	/* bit[7..0] int status, which is a read and clear register. */
@@ -109,22 +121,19 @@ static int kszphy_config_init(struct phy_device *phydev)
 
 static int ksz8021_config_init(struct phy_device *phydev)
 {
+	int rc;
 	const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
 	phy_write(phydev, MII_KSZPHY_OMSO, val);
-	return 0;
+	rc = ksz_config_flags(phydev);
+	return rc < 0 ? rc : 0;
 }
 
 static int ks8051_config_init(struct phy_device *phydev)
 {
-	int regval;
-
-	if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
-		regval = phy_read(phydev, MII_KSZPHY_CTRL);
-		regval |= KSZ8051_RMII_50MHZ_CLK;
-		phy_write(phydev, MII_KSZPHY_CTRL, regval);
-	}
+	int rc;
 
-	return 0;
+	rc = ksz_config_flags(phydev);
+	return rc < 0 ? rc : 0;
 }
 
 #define KSZ8873MLL_GLOBAL_CONTROL_4	0x06
-- 
1.7.9.5


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

* Re: [PATCH 1/2] phy/micrel: Add support for KSZ8031
  2013-03-11  8:50 [PATCH 1/2] phy/micrel: Add support for KSZ8031 Hector Palacios
  2013-03-11  8:50 ` [PATCH 2/2] phy/micrel: move flag handling to function for common use Hector Palacios
@ 2013-03-11 12:39 ` Marek Vasut
  2013-03-12 10:55   ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2013-03-11 12:39 UTC (permalink / raw)
  To: Hector Palacios; +Cc: netdev, linux-kernel, davem

Dear Hector Palacios,

> Micrel PHY KSZ8031 is similar to KSZ8021 and also requires the special
> initialization of "Operation Mode Strap Override" in reg 0x16
> introduced in 212ea99 (phy/micrel: Implement support for KSZ8021).
> 
> Signed-off-by: Hector Palacios <hector.palacios@digi.com>

I dont have any board with this one, yet I think this change is correct, so:

Reviewed-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

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

* Re: [PATCH 1/2] phy/micrel: Add support for KSZ8031
  2013-03-11 12:39 ` [PATCH 1/2] phy/micrel: Add support for KSZ8031 Marek Vasut
@ 2013-03-12 10:55   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-03-12 10:55 UTC (permalink / raw)
  To: marex; +Cc: hector.palacios, netdev, linux-kernel

From: Marek Vasut <marex@denx.de>
Date: Mon, 11 Mar 2013 13:39:46 +0100

> Dear Hector Palacios,
> 
>> Micrel PHY KSZ8031 is similar to KSZ8021 and also requires the special
>> initialization of "Operation Mode Strap Override" in reg 0x16
>> introduced in 212ea99 (phy/micrel: Implement support for KSZ8021).
>> 
>> Signed-off-by: Hector Palacios <hector.palacios@digi.com>
> 
> I dont have any board with this one, yet I think this change is correct, so:
> 
> Reviewed-by: Marek Vasut <marex@denx.de>

Applied.

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

* Re: [PATCH 2/2] phy/micrel: move flag handling to function for common use
  2013-03-11  8:50 ` [PATCH 2/2] phy/micrel: move flag handling to function for common use Hector Palacios
@ 2013-03-12 10:55   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-03-12 10:55 UTC (permalink / raw)
  To: hector.palacios; +Cc: netdev, linux-kernel, marex

From: Hector Palacios <hector.palacios@digi.com>
Date: Mon, 11 Mar 2013 09:50:03 +0100

> The flag MICREL_PHY_50MHZ_CLK is not of exclusive use of KSZ8051
> model. At least KSZ8021 and KSZ8031 models also use it.
> This patch moves the handling of this and future flags to a
> separate function so that the different PHY models can call it on
> their init function, if needed.
> 
> Signed-off-by: Hector Palacios <hector.palacios@digi.com>

Applied.

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

end of thread, other threads:[~2013-03-12 10:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-11  8:50 [PATCH 1/2] phy/micrel: Add support for KSZ8031 Hector Palacios
2013-03-11  8:50 ` [PATCH 2/2] phy/micrel: move flag handling to function for common use Hector Palacios
2013-03-12 10:55   ` David Miller
2013-03-11 12:39 ` [PATCH 1/2] phy/micrel: Add support for KSZ8031 Marek Vasut
2013-03-12 10:55   ` David Miller

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).