diff mbox

[net-next,2/2] net: phy: Marvell: Add mv88e6390 internal PHY

Message ID 1485309314-23942-3-git-send-email-andrew@lunn.ch
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Andrew Lunn Jan. 25, 2017, 1:55 a.m. UTC
The mv88e6390 Ethernet switch has internal PHYs. These PHYs don't have
an model ID in the ID2 register. So the MDIO driver in the switch
intercepts reads to this register, and returns the switch family ID.
Extend the Marvell PHY driver by including this ID, and tread the PHY
as a 88E1540.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/marvell.c   | 20 ++++++++++++++++++++
 include/linux/marvell_phy.h |  6 ++++++
 2 files changed, 26 insertions(+)

Comments

Gregory CLEMENT Jan. 26, 2017, 12:01 p.m. UTC | #1
Hi Andrew,
 
 On mer., janv. 25 2017, Andrew Lunn <andrew@lunn.ch> wrote:


> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index b5b73ff4329a..9debe1a4a6f6 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -2140,6 +2140,25 @@ static struct phy_driver marvell_drivers[] = {
>  		.get_strings = marvell_get_strings,
>  		.get_stats = marvell_get_stats,
>  	},
> +	{
> +		.phy_id = MARVELL_PHY_ID_88E6390,
> +		.phy_id_mask = MARVELL_PHY_ID_MASK,
> +		.name = "Marvell 88E6390",
> +		.features = PHY_GBIT_FEATURES,
> +		.flags = PHY_HAS_INTERRUPT,
> +		.probe = marvell_probe,

In order to get the temperature support I also had to modify the line
above by using m88e1510_probe instead of the marvell_probe. Indeed the
hwmon register was not done marvell_probe.

I think that you use marvell_probe because currently the value you get
are wrong for 6390. So either we have the 6390 which returns an
incorrect value for the temperature until you find the correct setting
or we introduce a new phy_id for the 6341 family with the hwmon support.

Gregory
Andrew Lunn Jan. 26, 2017, 2:16 p.m. UTC | #2
On Thu, Jan 26, 2017 at 01:01:06PM +0100, Gregory CLEMENT wrote:
> Hi Andrew,
>  
>  On mer., janv. 25 2017, Andrew Lunn <andrew@lunn.ch> wrote:
> 
> 
> > diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> > index b5b73ff4329a..9debe1a4a6f6 100644
> > --- a/drivers/net/phy/marvell.c
> > +++ b/drivers/net/phy/marvell.c
> > @@ -2140,6 +2140,25 @@ static struct phy_driver marvell_drivers[] = {
> >  		.get_strings = marvell_get_strings,
> >  		.get_stats = marvell_get_stats,
> >  	},
> > +	{
> > +		.phy_id = MARVELL_PHY_ID_88E6390,
> > +		.phy_id_mask = MARVELL_PHY_ID_MASK,
> > +		.name = "Marvell 88E6390",
> > +		.features = PHY_GBIT_FEATURES,
> > +		.flags = PHY_HAS_INTERRUPT,
> > +		.probe = marvell_probe,
> 
> In order to get the temperature support I also had to modify the line
> above by using m88e1510_probe instead of the marvell_probe. Indeed the
> hwmon register was not done marvell_probe.

Yes, this is historic.

These patches come from one branch where i have all my mv88e6390
code. I had them in the opposite order to what we have now. I had this
PHY work around first, and then the temperature sensor move patches.

But to get the code into mainline, i pulled the patches apart. The
temperature code has hit mainline first, now follow the PHY ID
workaround. I need to fix this probe call as a result.

Although the temperature sensor does not work yet for the 6390, i'm
going to assume it will at some point work. So i think it is O.K. to
use the same ID, and have the 6390 PHYs return -25000mC until we
figure out what is wrong.

       Andrew
diff mbox

Patch

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index b5b73ff4329a..9debe1a4a6f6 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -2140,6 +2140,25 @@  static struct phy_driver marvell_drivers[] = {
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
 	},
+	{
+		.phy_id = MARVELL_PHY_ID_88E6390,
+		.phy_id_mask = MARVELL_PHY_ID_MASK,
+		.name = "Marvell 88E6390",
+		.features = PHY_GBIT_FEATURES,
+		.flags = PHY_HAS_INTERRUPT,
+		.probe = marvell_probe,
+		.config_init = &marvell_config_init,
+		.config_aneg = &m88e1510_config_aneg,
+		.read_status = &marvell_read_status,
+		.ack_interrupt = &marvell_ack_interrupt,
+		.config_intr = &marvell_config_intr,
+		.did_interrupt = &m88e1121_did_interrupt,
+		.resume = &genphy_resume,
+		.suspend = &genphy_suspend,
+		.get_sset_count = marvell_get_sset_count,
+		.get_strings = marvell_get_strings,
+		.get_stats = marvell_get_stats,
+	},
 };
 
 module_phy_driver(marvell_drivers);
@@ -2158,6 +2177,7 @@  static struct mdio_device_id __maybe_unused marvell_tbl[] = {
 	{ MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
 	{ MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
 	{ MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
+	{ MARVELL_PHY_ID_88E6390, MARVELL_PHY_ID_MASK },
 	{ }
 };
 
diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
index a57f0dfb6db7..3d616d7f65bf 100644
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -19,6 +19,12 @@ 
 #define MARVELL_PHY_ID_88E1540		0x01410eb0
 #define MARVELL_PHY_ID_88E3016		0x01410e60
 
+/* The MV88e6390 Ethernet switch contains embedded PHYs. These PHYs do
+ * not have a model ID. So the switch driver traps reads to the ID2
+ * register and returns the switch family ID
+ */
+#define MARVELL_PHY_ID_88E6390		0x01410f90
+
 /* struct phy_device dev_flags definitions */
 #define MARVELL_PHY_M1145_FLAGS_RESISTANCE	0x00000001
 #define MARVELL_PHY_M1118_DNS323_LEDS		0x00000002