2014-07-09 12:24:30

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH 0/2] net: davinci_mdio: reuse for keystone2 arch

The similar MDIO HW blocks is used by keystone 2 SoCs as
in Davinci SoCs:
- one in Gigabit Ethernet (GbE) Switch Subsystem
See http://www.ti.com/lit/ug/sprugv9d/sprugv9d.pdf
- one in 10 Gigabit Ethernet Subsystem
See http://www.ti.com/lit/ug/spruhj5/spruhj5.pdf

Hence, reuse Davinci MDIO driver for Keystone 2 and
enable TI networking for Keystone 2 devices.

Also, as part of this series, enable PHY's creation from DT, because
Keystone 2 supports DT boot mode only.

Grygorii Strashko (2):
net: davinci_mdio: reuse for keystone2 arch
net: davinci_mdio: allow to create phys from dt

.../devicetree/bindings/net/davinci-mdio.txt | 8 ++++----
drivers/net/ethernet/ti/Kconfig | 4 ++--
drivers/net/ethernet/ti/davinci_mdio.c | 18 ++++++++++++++++--
3 files changed, 22 insertions(+), 8 deletions(-)

--
1.7.9.5


2014-07-09 12:24:32

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH 2/2] net: davinci_mdio: allow to create phys from dt

This patch allows to create PHYs from DT in case
if they are explicitly defined. The of_mdiobus_register() is
used for such purposes.

For backward compatibility, call of_mdiobus_register() only in case
if at least one PHY's child is defined in DT, otherwise rollback to
mdiobus_register().

Signed-off-by: Grygorii Strashko <[email protected]>
---
drivers/net/ethernet/ti/davinci_mdio.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 735dc53..22d3dab 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -38,6 +38,7 @@
#include <linux/davinci_emac.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/of_mdio.h>
#include <linux/pinctrl/consumer.h>

/*
@@ -95,6 +96,7 @@ struct davinci_mdio_data {
struct mii_bus *bus;
bool suspended;
unsigned long access_time; /* jiffies */
+ bool skip_scan;
};

static void __davinci_mdio_reset(struct davinci_mdio_data *data)
@@ -144,6 +146,9 @@ static int davinci_mdio_reset(struct mii_bus *bus)
dev_info(data->dev, "davinci mdio revision %d.%d\n",
(ver >> 8) & 0xff, ver & 0xff);

+ if (data->skip_scan)
+ return 0;
+
/* get phy mask from the alive register */
phy_mask = __raw_readl(&data->regs->alive);
if (phy_mask) {
@@ -369,8 +374,17 @@ static int davinci_mdio_probe(struct platform_device *pdev)
goto bail_out;
}

- /* register the mii bus */
- ret = mdiobus_register(data->bus);
+ /* register the mii bus
+ * Create PHYs from DT only in case if PHY child nodes are explicitly
+ * defined to support backward compatibility with DTs which assume that
+ * Davinci MDIO will always scan the bus for PHYs detection.
+ */
+ if (dev->of_node && of_get_child_count(dev->of_node)) {
+ data->skip_scan = true;
+ ret = of_mdiobus_register(data->bus, dev->of_node);
+ } else {
+ ret = mdiobus_register(data->bus);
+ }
if (ret)
goto bail_out;

--
1.7.9.5

2014-07-09 12:25:07

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

The similar MDIO HW blocks is used by keystone 2 SoCs as
in Davinci SoCs:
- one in Gigabit Ethernet (GbE) Switch Subsystem
See http://www.ti.com/lit/ug/sprugv9d/sprugv9d.pdf
- one in 10 Gigabit Ethernet Subsystem
See http://www.ti.com/lit/ug/spruhj5/spruhj5.pdf

Hence, reuse Davinci MDIO driver for Keystone 2 and
enable TI networking for Keystone 2 devices

Signed-off-by: Grygorii Strashko <[email protected]>
---
.../devicetree/bindings/net/davinci-mdio.txt | 8 ++++----
drivers/net/ethernet/ti/Kconfig | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/davinci-mdio.txt b/Documentation/devicetree/bindings/net/davinci-mdio.txt
index 72efaaf..d2e68e7 100644
--- a/Documentation/devicetree/bindings/net/davinci-mdio.txt
+++ b/Documentation/devicetree/bindings/net/davinci-mdio.txt
@@ -1,8 +1,8 @@
-TI SoC Davinci MDIO Controller Device Tree Bindings
+TI SoC Davinci/Keystone2 MDIO Controller Device Tree Bindings
---------------------------------------------------

Required properties:
-- compatible : Should be "ti,davinci_mdio"
+- compatible : Should be "ti,davinci_mdio" or "ti,keystone-mdio"
- reg : physical base address and size of the davinci mdio
registers map
- bus_freq : Mdio Bus frequency
@@ -19,7 +19,7 @@ file.
Examples:

mdio: davinci_mdio@4A101000 {
- compatible = "ti,cpsw";
+ compatible = "ti,davinci_mdio";
reg = <0x4A101000 0x1000>;
bus_freq = <1000000>;
};
@@ -27,7 +27,7 @@ Examples:
(or)

mdio: davinci_mdio@4A101000 {
- compatible = "ti,cpsw";
+ compatible = "ti,davinci_mdio";
ti,hwmods = "davinci_mdio";
bus_freq = <1000000>;
};
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index 53150c2..1769700 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -5,7 +5,7 @@
config NET_VENDOR_TI
bool "Texas Instruments (TI) devices"
default y
- depends on PCI || EISA || AR7 || (ARM && (ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX))
+ depends on PCI || EISA || AR7 || (ARM && (ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX || ARCH_KEYSTONE))
---help---
If you have a network (Ethernet) card belonging to this class, say Y
and read the Ethernet-HOWTO, available from
@@ -32,7 +32,7 @@ config TI_DAVINCI_EMAC

config TI_DAVINCI_MDIO
tristate "TI DaVinci MDIO Support"
- depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX )
+ depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX || ARCH_KEYSTONE )
select PHYLIB
---help---
This driver supports TI's DaVinci MDIO module.
--
1.7.9.5

2014-07-09 14:20:38

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

On Wednesday 09 July 2014 09:10 AM, Grygorii Strashko wrote:
> The similar MDIO HW blocks is used by keystone 2 SoCs as
> in Davinci SoCs:
> - one in Gigabit Ethernet (GbE) Switch Subsystem
> See http://www.ti.com/lit/ug/sprugv9d/sprugv9d.pdf
> - one in 10 Gigabit Ethernet Subsystem
> See http://www.ti.com/lit/ug/spruhj5/spruhj5.pdf
>
> Hence, reuse Davinci MDIO driver for Keystone 2 and
> enable TI networking for Keystone 2 devices
>
> Signed-off-by: Grygorii Strashko <[email protected]>
> ---
Looks good to me.
Reviewed-by: Santosh Shilimkar <[email protected]>

> .../devicetree/bindings/net/davinci-mdio.txt | 8 ++++----
> drivers/net/ethernet/ti/Kconfig | 4 ++--
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/davinci-mdio.txt b/Documentation/devicetree/bindings/net/davinci-mdio.txt
> index 72efaaf..d2e68e7 100644
> --- a/Documentation/devicetree/bindings/net/davinci-mdio.txt
> +++ b/Documentation/devicetree/bindings/net/davinci-mdio.txt
> @@ -1,8 +1,8 @@
> -TI SoC Davinci MDIO Controller Device Tree Bindings
> +TI SoC Davinci/Keystone2 MDIO Controller Device Tree Bindings
> ---------------------------------------------------
>
> Required properties:
> -- compatible : Should be "ti,davinci_mdio"
> +- compatible : Should be "ti,davinci_mdio" or "ti,keystone-mdio"
> - reg : physical base address and size of the davinci mdio
> registers map
> - bus_freq : Mdio Bus frequency
> @@ -19,7 +19,7 @@ file.
> Examples:
>
> mdio: davinci_mdio@4A101000 {
> - compatible = "ti,cpsw";
> + compatible = "ti,davinci_mdio";
> reg = <0x4A101000 0x1000>;
> bus_freq = <1000000>;
> };
> @@ -27,7 +27,7 @@ Examples:
> (or)
>
> mdio: davinci_mdio@4A101000 {
> - compatible = "ti,cpsw";
> + compatible = "ti,davinci_mdio";
> ti,hwmods = "davinci_mdio";
> bus_freq = <1000000>;
> };
> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
> index 53150c2..1769700 100644
> --- a/drivers/net/ethernet/ti/Kconfig
> +++ b/drivers/net/ethernet/ti/Kconfig
> @@ -5,7 +5,7 @@
> config NET_VENDOR_TI
> bool "Texas Instruments (TI) devices"
> default y
> - depends on PCI || EISA || AR7 || (ARM && (ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX))
> + depends on PCI || EISA || AR7 || (ARM && (ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX || ARCH_KEYSTONE))
> ---help---
> If you have a network (Ethernet) card belonging to this class, say Y
> and read the Ethernet-HOWTO, available from
> @@ -32,7 +32,7 @@ config TI_DAVINCI_EMAC
>
> config TI_DAVINCI_MDIO
> tristate "TI DaVinci MDIO Support"
> - depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX )
> + depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX || ARCH_KEYSTONE )
> select PHYLIB
> ---help---
> This driver supports TI's DaVinci MDIO module.
>

2014-07-09 14:23:40

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH 2/2] net: davinci_mdio: allow to create phys from dt

On Wednesday 09 July 2014 09:10 AM, Grygorii Strashko wrote:
> This patch allows to create PHYs from DT in case
> if they are explicitly defined. The of_mdiobus_register() is
> used for such purposes.
>
> For backward compatibility, call of_mdiobus_register() only in case
> if at least one PHY's child is defined in DT, otherwise rollback to
> mdiobus_register().
>
> Signed-off-by: Grygorii Strashko <[email protected]>
> ---
> drivers/net/ethernet/ti/davinci_mdio.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index 735dc53..22d3dab 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -38,6 +38,7 @@
> #include <linux/davinci_emac.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
> #include <linux/pinctrl/consumer.h>
>
> /*
> @@ -95,6 +96,7 @@ struct davinci_mdio_data {
> struct mii_bus *bus;
> bool suspended;
> unsigned long access_time; /* jiffies */
> + bool skip_scan;
The vairiable name is not too intutive so probably add a little
bit description on what are you skipping with it.

> };
>
> static void __davinci_mdio_reset(struct davinci_mdio_data *data)
> @@ -144,6 +146,9 @@ static int davinci_mdio_reset(struct mii_bus *bus)
> dev_info(data->dev, "davinci mdio revision %d.%d\n",
> (ver >> 8) & 0xff, ver & 0xff);
>
> + if (data->skip_scan)
> + return 0;
> +
> /* get phy mask from the alive register */
> phy_mask = __raw_readl(&data->regs->alive);
> if (phy_mask) {
> @@ -369,8 +374,17 @@ static int davinci_mdio_probe(struct platform_device *pdev)
> goto bail_out;
> }
>
> - /* register the mii bus */
> - ret = mdiobus_register(data->bus);
> + /* register the mii bus
> + * Create PHYs from DT only in case if PHY child nodes are explicitly
> + * defined to support backward compatibility with DTs which assume that
> + * Davinci MDIO will always scan the bus for PHYs detection.
> + */
multi line comment is not as per coding style. Please fix that.
Patch as such looks good to me so with those minor fixes, feel
free to append my review tag.

Reviewed-by: Santosh Shilimkar <[email protected]>

> + if (dev->of_node && of_get_child_count(dev->of_node)) {
> + data->skip_scan = true;
> + ret = of_mdiobus_register(data->bus, dev->of_node);
> + } else {
> + ret = mdiobus_register(data->bus);
> + }
> if (ret)
> goto bail_out;
>
>

2014-07-09 23:52:35

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

From: Grygorii Strashko <[email protected]>
Date: Wed, 9 Jul 2014 16:10:50 +0300

> Required properties:
> -- compatible : Should be "ti,davinci_mdio"
> +- compatible : Should be "ti,davinci_mdio" or "ti,keystone-mdio"

Why the inconsistency in naming schemes? I don't see any reason
to be different wrt. "_" vs. "-" in the name string.

2014-07-10 12:12:11

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

Hi David,

On 07/10/2014 02:52 AM, David Miller wrote:
> From: Grygorii Strashko <[email protected]>
> Date: Wed, 9 Jul 2014 16:10:50 +0300
>
>> Required properties:
>> -- compatible : Should be "ti,davinci_mdio"
>> +- compatible : Should be "ti,davinci_mdio" or "ti,keystone-mdio"
>
> Why the inconsistency in naming schemes? I don't see any reason
> to be different wrt. "_" vs. "-" in the name string.
>

Hm. Looks like the common way is to use "-", but I can rename it if you insist.

Regards,
-grygorii

2014-07-10 12:29:05

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH 2/2] net: davinci_mdio: allow to create phys from dt

On 07/09/2014 05:23 PM, Santosh Shilimkar wrote:
> On Wednesday 09 July 2014 09:10 AM, Grygorii Strashko wrote:
>> This patch allows to create PHYs from DT in case
>> if they are explicitly defined. The of_mdiobus_register() is
>> used for such purposes.
>>
>> For backward compatibility, call of_mdiobus_register() only in case
>> if at least one PHY's child is defined in DT, otherwise rollback to
>> mdiobus_register().
>>
>> Signed-off-by: Grygorii Strashko <[email protected]>
>> ---
>> drivers/net/ethernet/ti/davinci_mdio.c | 18 ++++++++++++++++--
>> 1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
>> index 735dc53..22d3dab 100644
>> --- a/drivers/net/ethernet/ti/davinci_mdio.c
>> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
>> @@ -38,6 +38,7 @@
>> #include <linux/davinci_emac.h>
>> #include <linux/of.h>
>> #include <linux/of_device.h>
>> +#include <linux/of_mdio.h>
>> #include <linux/pinctrl/consumer.h>
>>
>> /*
>> @@ -95,6 +96,7 @@ struct davinci_mdio_data {
>> struct mii_bus *bus;
>> bool suspended;
>> unsigned long access_time; /* jiffies */

/*
* Indicates that driver shouldn't modify phy_mask in case
* if MDIO bus is registered from DT.
*/

>> + bool skip_scan;
> The vairiable name is not too intutive so probably add a little
> bit description on what are you skipping with it.


Now the Davinci MDIO driver updates mii_bus->phy_mask from
its reset routine to limit number of phy addresses to be scanned.

The MDIO bus scanning has to be skipped at all in case of DT MDIO registration.
And of_mdiobus_register() maintain mii_bus->phy_mask by itself,
thus driver shouldn't touch it.

I'll add above comment. Is it ok?


>
>> };
>>
>> static void __davinci_mdio_reset(struct davinci_mdio_data *data)
>> @@ -144,6 +146,9 @@ static int davinci_mdio_reset(struct mii_bus *bus)
>> dev_info(data->dev, "davinci mdio revision %d.%d\n",
>> (ver >> 8) & 0xff, ver & 0xff);
>>
>> + if (data->skip_scan)
>> + return 0;
>> +
>> /* get phy mask from the alive register */
>> phy_mask = __raw_readl(&data->regs->alive);
>> if (phy_mask) {
>> @@ -369,8 +374,17 @@ static int davinci_mdio_probe(struct platform_device *pdev)
>> goto bail_out;
>> }
>>
>> - /* register the mii bus */
>> - ret = mdiobus_register(data->bus);
>> + /* register the mii bus
>> + * Create PHYs from DT only in case if PHY child nodes are explicitly
>> + * defined to support backward compatibility with DTs which assume that
>> + * Davinci MDIO will always scan the bus for PHYs detection.
>> + */
> multi line comment is not as per coding style. Please fix that.
> Patch as such looks good to me so with those minor fixes, feel
> free to append my review tag.

will fix it.

>
> Reviewed-by: Santosh Shilimkar <[email protected]>
>
>> + if (dev->of_node && of_get_child_count(dev->of_node)) {
>> + data->skip_scan = true;
>> + ret = of_mdiobus_register(data->bus, dev->of_node);
>> + } else {
>> + ret = mdiobus_register(data->bus);
>> + }
>> if (ret)
>> goto bail_out;
>>
>>
>

2014-07-10 19:39:04

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

From: Grygorii Strashko <[email protected]>
Date: Thu, 10 Jul 2014 15:58:31 +0300

> Hi David,
>
> On 07/10/2014 02:52 AM, David Miller wrote:
>> From: Grygorii Strashko <[email protected]>
>> Date: Wed, 9 Jul 2014 16:10:50 +0300
>>
>>> Required properties:
>>> -- compatible : Should be "ti,davinci_mdio"
>>> +- compatible : Should be "ti,davinci_mdio" or "ti,keystone-mdio"
>>
>> Why the inconsistency in naming schemes? I don't see any reason
>> to be different wrt. "_" vs. "-" in the name string.
>>
>
> Hm. Looks like the common way is to use "-", but I can rename it if you insist.

I'm just saying, is there a strong reason to be inconsistent?

2014-07-11 05:04:03

by Mugunthan V N

[permalink] [raw]
Subject: Re: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

On Wednesday 09 July 2014 06:40 PM, Grygorii Strashko wrote:
> The similar MDIO HW blocks is used by keystone 2 SoCs as
> in Davinci SoCs:
> - one in Gigabit Ethernet (GbE) Switch Subsystem
> See http://www.ti.com/lit/ug/sprugv9d/sprugv9d.pdf
> - one in 10 Gigabit Ethernet Subsystem
> See http://www.ti.com/lit/ug/spruhj5/spruhj5.pdf
>
> Hence, reuse Davinci MDIO driver for Keystone 2 and
> enable TI networking for Keystone 2 devices
>
> Signed-off-by: Grygorii Strashko <[email protected]>

Acked-by: Mugunthan V N <[email protected]>

Regards
Mugunthan V N

2014-07-11 05:05:24

by Mugunthan V N

[permalink] [raw]
Subject: Re: [PATCH 2/2] net: davinci_mdio: allow to create phys from dt

On Wednesday 09 July 2014 06:40 PM, Grygorii Strashko wrote:
> This patch allows to create PHYs from DT in case
> if they are explicitly defined. The of_mdiobus_register() is
> used for such purposes.
>
> For backward compatibility, call of_mdiobus_register() only in case
> if at least one PHY's child is defined in DT, otherwise rollback to
> mdiobus_register().
>
> Signed-off-by: Grygorii Strashko <[email protected]>

Except Santhosh comment patch looks good to me.

Acked-by: Mugunthan V N <[email protected]>

Regards
Mugunthan V N

2014-07-11 09:38:36

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH 1/2] net: davinci_mdio: reuse for keystone2 arch

On 07/10/2014 10:39 PM, David Miller wrote:
> From: Grygorii Strashko <[email protected]>
> Date: Thu, 10 Jul 2014 15:58:31 +0300
>
>> Hi David,
>>
>> On 07/10/2014 02:52 AM, David Miller wrote:
>>> From: Grygorii Strashko <[email protected]>
>>> Date: Wed, 9 Jul 2014 16:10:50 +0300
>>>
>>>> Required properties:
>>>> -- compatible : Should be "ti,davinci_mdio"
>>>> +- compatible : Should be "ti,davinci_mdio" or "ti,keystone-mdio"
>>>
>>> Why the inconsistency in naming schemes? I don't see any reason
>>> to be different wrt. "_" vs. "-" in the name string.
>>>
>>
>> Hm. Looks like the common way is to use "-", but I can rename it if you insist.
>
> I'm just saying, is there a strong reason to be inconsistent?
>

I've followed the same format as for all latest compatibility strings in
Kernel. Also I've checked ePAPR and dash is used for all examples there.

"ti,davinci_mdio" was added 2 years ago, so possibly no strict
convention or review were done then. Now, I can't change
"ti,davinci_mdio" -> "ti,davinci-mdio" to be consistent with Kernel due
to compatibility issues.

May be DT Gurus can say more?


Regards,
-grygorii