diff mbox

[v1] net: phy: micrel: add KSZ8795 ethernet switch

Message ID 20170123075846.12888-1-sean.nyekjaer@prevas.dk
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Sean Nyekjær Jan. 23, 2017, 7:58 a.m. UTC
This is add support for the PHYs in the KSZ8795 5port managed switch.

It will allow to detect the link between the switch and the soc
and uses the same read_status functions as the KSZ8873MLL switch.

This ethernet switch have unfortunately the same phy id as KSZ8051.

Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
---
 drivers/net/phy/micrel.c   | 14 ++++++++++++++
 include/linux/micrel_phy.h |  2 ++
 2 files changed, 16 insertions(+)

Comments

Andrew Lunn Jan. 23, 2017, 3:12 p.m. UTC | #1
On Mon, Jan 23, 2017 at 08:58:46AM +0100, Sean Nyekjaer wrote:
> This is add support for the PHYs in the KSZ8795 5port managed switch.
> 
> It will allow to detect the link between the switch and the soc
> and uses the same read_status functions as the KSZ8873MLL switch.
> 
> This ethernet switch have unfortunately the same phy id as KSZ8051.
> 
> Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
> ---
>  drivers/net/phy/micrel.c   | 14 ++++++++++++++
>  include/linux/micrel_phy.h |  2 ++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index ea92d524d5a8..fa158ae5115b 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1014,6 +1014,20 @@ static struct phy_driver ksphy_driver[] = {
>  	.get_stats	= kszphy_get_stats,
>  	.suspend	= genphy_suspend,
>  	.resume		= genphy_resume,
> +}, {
> +	.phy_id		= PHY_ID_KSZ8795,
> +	.phy_id_mask	= MICREL_PHY_ID_MASK,
> +	.name		= "Micrel KSZ8795 Switch",

This name is confusing. You are adding support for the PHYs embedded
in the switch, not the switch itself. The phylib has no idea these
PHYs are inside a switch. It does not matter. It is just a PHY. Please
drop the word "Switch".

Thanks
	Andrew
Sean Nyekjær Jan. 26, 2017, 5:51 p.m. UTC | #2
On 2017-01-23 16:12, Andrew Lunn wrote:
> On Mon, Jan 23, 2017 at 08:58:46AM +0100, Sean Nyekjaer wrote:
>> This is add support for the PHYs in the KSZ8795 5port managed switch.
>>
>> It will allow to detect the link between the switch and the soc
>> and uses the same read_status functions as the KSZ8873MLL switch.
>>
>> This ethernet switch have unfortunately the same phy id as KSZ8051.
>>
>> Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
>> ---
>>   drivers/net/phy/micrel.c   | 14 ++++++++++++++
>>   include/linux/micrel_phy.h |  2 ++
>>   2 files changed, 16 insertions(+)
>>
>> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
>> index ea92d524d5a8..fa158ae5115b 100644
>> --- a/drivers/net/phy/micrel.c
>> +++ b/drivers/net/phy/micrel.c
>> @@ -1014,6 +1014,20 @@ static struct phy_driver ksphy_driver[] = {
>>   	.get_stats	= kszphy_get_stats,
>>   	.suspend	= genphy_suspend,
>>   	.resume		= genphy_resume,
>> +}, {
>> +	.phy_id		= PHY_ID_KSZ8795,
>> +	.phy_id_mask	= MICREL_PHY_ID_MASK,
>> +	.name		= "Micrel KSZ8795 Switch",
> This name is confusing. You are adding support for the PHYs embedded
> in the switch, not the switch itself. The phylib has no idea these
> PHYs are inside a switch. It does not matter. It is just a PHY. Please
> drop the word "Switch".
>
> Thanks
> 	Andrew
Okay i'll understand :-)
I remove the word "Switch" from the commit message and phy name.
The rest is okay?
What is generally being done when to phy's have the same id, micrel have 
done this many times...

/Sean
Andrew Lunn Jan. 26, 2017, 6:12 p.m. UTC | #3
> I remove the word "Switch" from the commit message and phy name.
> The rest is okay?

Yes.

> What is generally being done when to phy's have the same id, micrel
> have done this many times...

It should not be a problem. When you write a switch driver for the
switch, it will be in device tree. Look at the Marvell Switches as an
example. Switches don't probe based on the ID in registers 2 and 3,
because switches often respond to many different addresses, or don't
have an ID in register 2 and 3.

So it should not matter if the switch and the PHYs embedded in the
switch have the same ID.

When do you plan to post your switch driver?

       Andrew
Florian Fainelli Jan. 26, 2017, 6:36 p.m. UTC | #4
On 01/26/2017 09:51 AM, Sean Nyekjær wrote:
> 
> 
> On 2017-01-23 16:12, Andrew Lunn wrote:
>> On Mon, Jan 23, 2017 at 08:58:46AM +0100, Sean Nyekjaer wrote:
>>> This is add support for the PHYs in the KSZ8795 5port managed switch.
>>>
>>> It will allow to detect the link between the switch and the soc
>>> and uses the same read_status functions as the KSZ8873MLL switch.
>>>
>>> This ethernet switch have unfortunately the same phy id as KSZ8051.
>>>
>>> Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
>>> ---
>>>   drivers/net/phy/micrel.c   | 14 ++++++++++++++
>>>   include/linux/micrel_phy.h |  2 ++
>>>   2 files changed, 16 insertions(+)
>>>
>>> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
>>> index ea92d524d5a8..fa158ae5115b 100644
>>> --- a/drivers/net/phy/micrel.c
>>> +++ b/drivers/net/phy/micrel.c
>>> @@ -1014,6 +1014,20 @@ static struct phy_driver ksphy_driver[] = {
>>>       .get_stats    = kszphy_get_stats,
>>>       .suspend    = genphy_suspend,
>>>       .resume        = genphy_resume,
>>> +}, {
>>> +    .phy_id        = PHY_ID_KSZ8795,
>>> +    .phy_id_mask    = MICREL_PHY_ID_MASK,
>>> +    .name        = "Micrel KSZ8795 Switch",
>> This name is confusing. You are adding support for the PHYs embedded
>> in the switch, not the switch itself. The phylib has no idea these
>> PHYs are inside a switch. It does not matter. It is just a PHY. Please
>> drop the word "Switch".
>>
>> Thanks
>>     Andrew
> Okay i'll understand :-)
> I remove the word "Switch" from the commit message and phy name.
> The rest is okay?
> What is generally being done when to phy's have the same id, micrel have
> done this many times...

You need unique names, we have a case like that in
drivers/net/phy/bcm7xxx.c for the 7439 PHY where it exists with two
different IDs, so the first one is named "Broadcom BCM7439" and the
second one is named "Broadcom BCM7439 (2)", feel free to adopt the same
convention, or something else.

The rest of your patch is okay.
Sean Nyekjær Jan. 27, 2017, 7:42 a.m. UTC | #5
On 2017-01-26 19:12, Andrew Lunn wrote:
>> I remove the word "Switch" from the commit message and phy name.
>> The rest is okay?
> Yes.
>
>> What is generally being done when to phy's have the same id, micrel
>> have done this many times...
> It should not be a problem. When you write a switch driver for the
> switch, it will be in device tree. Look at the Marvell Switches as an
> example. Switches don't probe based on the ID in registers 2 and 3,
> because switches often respond to many different addresses, or don't
> have an ID in register 2 and 3.
>
> So it should not matter if the switch and the PHYs embedded in the
> switch have the same ID.
>
> When do you plan to post your switch driver?
>
>         Andrew
I was not planning on doing that, the managed part of the switch is not 
needed in the project i'm working on.
Maybe i will do it when i have some spare time, it could be fun :-)

/Sean
diff mbox

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index ea92d524d5a8..fa158ae5115b 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1014,6 +1014,20 @@  static struct phy_driver ksphy_driver[] = {
 	.get_stats	= kszphy_get_stats,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
+}, {
+	.phy_id		= PHY_ID_KSZ8795,
+	.phy_id_mask	= MICREL_PHY_ID_MASK,
+	.name		= "Micrel KSZ8795 Switch",
+	.features	= (SUPPORTED_Pause | SUPPORTED_Asym_Pause),
+	.flags		= PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
+	.config_init	= kszphy_config_init,
+	.config_aneg	= ksz8873mll_config_aneg,
+	.read_status	= ksz8873mll_read_status,
+	.get_sset_count = kszphy_get_sset_count,
+	.get_strings	= kszphy_get_strings,
+	.get_stats	= kszphy_get_stats,
+	.suspend	= genphy_suspend,
+	.resume		= genphy_resume,
 } };
 
 module_phy_driver(ksphy_driver);
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 257173e0095e..f541da68d1e7 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -35,6 +35,8 @@ 
 #define PHY_ID_KSZ886X		0x00221430
 #define PHY_ID_KSZ8863		0x00221435
 
+#define PHY_ID_KSZ8795		0x00221550
+
 /* struct phy_device dev_flags definitions */
 #define MICREL_PHY_50MHZ_CLK	0x00000001
 #define MICREL_PHY_FXEN		0x00000002