Discussion:
[PATCH 4/5 v2] ARM: orion5x: add gigabit ethernet device tree node
(too old to reply)
Florian Fainelli
2013-04-04 10:27:14 UTC
Permalink
This patch adds the gigabit ethernet device tree node to orion5x.dtsi.
This node is disabled by default and must be enabled on a per-board
basis. For completeness and easier testing the MDIO node is also added
and disabled by default.

Signed-off-by: Florian Fainelli <***@openwrt.org>
---
Changes since v1:
- fixed off-by 0x2000 address of the ethernet-group node

arch/arm/boot/dts/orion5x.dtsi | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/arch/arm/boot/dts/orion5x.dtsi b/arch/arm/boot/dts/orion5x.dtsi
index f7bec3b..c49503e 100644
--- a/arch/arm/boot/dts/orion5x.dtsi
+++ b/arch/arm/boot/dts/orion5x.dtsi
@@ -99,5 +99,28 @@
interrupts = <28>;
status = "okay";
};
+
+ ***@72004 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
+ status = "disabled";
+ };
+
+ ethernet-***@72000 {
+ #address-cells = <1>.
+ #size-cells = <0>;
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x72000 0x4000>;
+ status = "disabled";
+
+ egiga0: ***@0 {
+ device_type = "network";
+ compatible = "marvell,mv643xx-eth";
+ reg = <0>;
+ interrupts = <21>;
+ };
+ };
};
};
--
1.7.10.4
Florian Fainelli
2013-04-04 10:27:13 UTC
Permalink
This patch modifies kirkwood.dtsi to specify the various gigabit
interfaces nodes available on kirkwood devices. They are disabled by
default and should be enabled on a per-board basis. egiga0 and egiga1
aliases are defined for convenience. The mdio node is also present and
should be enabled on a per-board basis as well.

Signed-off-by: Florian Fainelli <***@openwrt.org>
---
Changes since v1:
- dropped change to arch/arm/mach-kirkwood/common.c to avoid merge conflicts
- fixed off-by 0x2000 ethernet-group nodes address

arch/arm/boot/dts/kirkwood.dtsi | 46 +++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index fada7e6..254f5a8 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -7,6 +7,8 @@
aliases {
gpio0 = &gpio0;
gpio1 = &gpio1;
+ egiga0 = &egiga0;
+ egiga1 = &egiga1;
};
intc: interrupt-controller {
compatible = "marvell,orion-intc", "marvell,intc";
@@ -202,5 +204,49 @@
clocks = <&gate_clk 4>;
status = "disabled";
};
+
+ ***@72004 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
+ status = "disabled";
+ };
+
+ ethernet-***@72000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x72000 0x4000>;
+ tx-csum-limit = <1600>;
+ status = "disabled";
+
+ egiga0: ***@0 {
+ device_type = "network";
+ compatible = "marvell,mv643xx-eth";
+ reg = <0>;
+ interrupts = <11>;
+ clocks = <&gate_clk 0>;
+ clock-names = "0";
+ };
+ };
+
+ ethernet-***@76000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x76000 0x4000>;
+ tx-csum-limit = <1600>;
+ status = "disabled";
+
+ egiga1: ***@0 {
+ device_type = "network";
+ compatible = "marvell,mv643xx-eth";
+ reg = <0>;
+ interrupts = <15>;
+ clocks = <&gate_clk 19>;
+ clock-names = "1";
+ };
+ };
};
};
--
1.7.10.4
Simon Baatz
2013-04-04 21:35:17 UTC
Permalink
Hi Florian,
Post by Florian Fainelli
This patch modifies kirkwood.dtsi to specify the various gigabit
interfaces nodes available on kirkwood devices. They are disabled by
default and should be enabled on a per-board basis. egiga0 and egiga1
aliases are defined for convenience. The mdio node is also present and
should be enabled on a per-board basis as well.
---
- dropped change to arch/arm/mach-kirkwood/common.c to avoid merge conflicts
I think we should remove the clock aliases in
kirkwood_legacy_clk_init() in mach-kirkwood/dt-board.c (once we have
proper clock support, see my other mail).
Post by Florian Fainelli
- fixed off-by 0x2000 ethernet-group nodes address
arch/arm/boot/dts/kirkwood.dtsi | 46 +++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index fada7e6..254f5a8 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -7,6 +7,8 @@
aliases {
gpio0 = &gpio0;
gpio1 = &gpio1;
+ egiga0 = &egiga0;
+ egiga1 = &egiga1;
};
intc: interrupt-controller {
compatible = "marvell,orion-intc", "marvell,intc";
@@ -202,5 +204,49 @@
clocks = <&gate_clk 4>;
status = "disabled";
};
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
Don't we need to add:

interrupts = <46>;

here?


- Simon
Florian Fainelli
2013-04-05 09:21:50 UTC
Permalink
Post by Simon Baatz
Hi Florian,
Post by Florian Fainelli
This patch modifies kirkwood.dtsi to specify the various gigabit
interfaces nodes available on kirkwood devices. They are disabled by
default and should be enabled on a per-board basis. egiga0 and egiga1
aliases are defined for convenience. The mdio node is also present and
should be enabled on a per-board basis as well.
---
- dropped change to arch/arm/mach-kirkwood/common.c to avoid merge conflicts
I think we should remove the clock aliases in
kirkwood_legacy_clk_init() in mach-kirkwood/dt-board.c (once we have
proper clock support, see my other mail).
[snip]
Post by Simon Baatz
interrupts = <46>;
here?
Right this is missing, in fact it still works ok because the orion-mdio
driver can do busy waiting instead of interrupt signaling. Will fix that
in the next round, thanks!
--
Florian
Florian Fainelli
2013-04-04 10:27:15 UTC
Permalink
This patch adds the gigabit ethernet device tree nodes to dove.dtsi in a
disabled state. The gigabit ethernet device tree node must be enabled on
a per-board basis. For completeness and easier testing the MDIO node is
also added in a disabled state.

Signed-off-by: Florian Fainelli <***@openwrt.org>
---
Changes since v1:
- fixed off-by 0x2000 address of the ethernet-group node

arch/arm/boot/dts/dove.dtsi | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index f7509ca..51de5f7 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -253,5 +253,30 @@
dmacap,xor;
};
};
+
+ ***@72004 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
+ status = "disabled";
+ };
+
+ ethernet-***@72000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x72000 0x4000>;
+ tx-csum-limit = <1600>;
+ status = "disabled";
+
+ egiga0: ***@0 {
+ device_type = "network";
+ compatible = "marvell,mv643xx-eth";
+ reg = <0>;
+ interrupts = <29>;
+ clocks = <&gate_clk 2>;
+ };
+ };
};
};
--
1.7.10.4
Florian Fainelli
2013-04-04 10:27:12 UTC
Permalink
This patch updates the Device Tree bindings documentation for the
Marvell MV643xx ethernet controller node and makes the
"local-mac-address" and "phy" properties optional instead of required.
The absence of a "phy" node is legal and describes a MAC to switch
configuration, while not specifying the "local-mac-address" allows for
reuse of the MAC address already programmed into the Ethernet
controller.

Signed-off-by: Florian Fainelli <***@openwrt.org>
---
Documentation/devicetree/bindings/marvell.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt
index e70a013..994b933 100644
--- a/Documentation/devicetree/bindings/marvell.txt
+++ b/Documentation/devicetree/bindings/marvell.txt
@@ -141,11 +141,11 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
- interrupts : <a> where a is the interrupt number for the port.
- interrupt-parent : the phandle for the interrupt controller
that services interrupts for this device.
+
+ Optional properties:
- phy : the phandle for the PHY connected to this ethernet
controller.
- local-mac-address : 6 bytes, MAC address
-
- Optional properties:
- clocks : Phandle to the clock control device and gate bit
- clock-names : String describing the clock gate bit
- speed : Speed to force the link (10, 100, 1000), used when no
--
1.7.10.4
Florian Fainelli
2013-04-04 10:27:11 UTC
Permalink
This patch adds Device Tree bindings following the already defined
bindings at Documentation/devicetree/bindings/marvell.txt. The binding
documentation is also enhanced with new optionnal properties required
for supporting certain devices (RX/TX queue and SRAM). Since we now have
proper support for the orion MDIO bus driver, there is no need to fiddle
around with device tree phandles. PHY-less (MAC connected to switch)
configurations are supported by not specifying any phy phandle for an
ethernet node.

Signed-off-by: Florian Fainelli <***@openwrt.org>
---
- properly ifdef of_platform_bus_probe with CONFIG_OF
- handle of_platform_bus_probe errors and cleanup accordingly
- use of_property_read_u32 where applicable
- parse "duplex" and "speed" property in PHY-less configuration

Documentation/devicetree/bindings/marvell.txt | 25 +++++-
drivers/net/ethernet/marvell/mv643xx_eth.c | 120 ++++++++++++++++++++++++-
2 files changed, 140 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt
index f1533d9..e70a013 100644
--- a/Documentation/devicetree/bindings/marvell.txt
+++ b/Documentation/devicetree/bindings/marvell.txt
@@ -112,9 +112,14 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
Required properties:
- #address-cells : <1>
- #size-cells : <0>
- - compatible : "marvell,mv64360-eth-block"
+ - compatible : "marvell,mv64360-eth-block", "marvell,mv64360-eth-group",
+ "marvell,mv643xx-eth-block"
- reg : Offset and length of the register set for this block

+ Optional properties:
+ - tx-csum-limit : Hardware limit above which transmit checksumming
+ is disabled.
+
Example Discovery Ethernet block node:
ethernet-***@2000 {
#address-cells = <1>;
@@ -130,7 +135,7 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.

Required properties:
- device_type : Should be "network".
- - compatible : Should be "marvell,mv64360-eth".
+ - compatible : Should be "marvell,mv64360-eth", "marvell,mv643xx-eth".
- reg : Should be <0>, <1>, or <2>, according to which registers
within the silicon block the device uses.
- interrupts : <a> where a is the interrupt number for the port.
@@ -140,6 +145,22 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
controller.
- local-mac-address : 6 bytes, MAC address

+ Optional properties:
+ - clocks : Phandle to the clock control device and gate bit
+ - clock-names : String describing the clock gate bit
+ - speed : Speed to force the link (10, 100, 1000), used when no
+ phy property is defined
+ - duplex : Duplex to force the link (0: half, 1: full), used when no
+ phy property is defined
+ - rx-queue-count : number of RX queues to use
+ - tx-queue-count : number of TX queues to use
+ - rx-queue-size : size of the RX queue (in bytes)
+ - tx-queue-size : size of the TX queue (in bytes)
+ - rx-sram-addr : address of the SRAM for RX path (non 0 means used)
+ - rx-sram-size : size of the SRAM for RX path (non 0 means used)
+ - tx-sram-addr : address of the SRAM for TX path (non 0 means used)
+ - tx-sram-size : size of the SRAM for TX path (non 0 means used)
+
Example Discovery Ethernet port node:
***@0 {
device_type = "network";
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index aedbd82..75599a8 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -60,6 +60,10 @@
#include <linux/inet_lro.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/stringify.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_net.h>

static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4";
@@ -2542,14 +2546,23 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
}
}

+static const struct of_device_id mv643xx_eth_match[] = {
+ { .compatible = "marvell,mv64360-eth" },
+ { .compatible = "marvell,mv643xx-eth" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_match);
+
static int mv643xx_eth_shared_probe(struct platform_device *pdev)
{
static int mv643xx_eth_version_printed;
+ struct device_node *np = pdev->dev.of_node;
struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
struct mv643xx_eth_shared_private *msp;
const struct mbus_dram_target_info *dram;
struct resource *res;
int ret;
+ int tx_csum_limit = 0;

if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
@@ -2576,13 +2589,23 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);

- msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
- pd->tx_csum_limit : 9 * 1024;
+ if (np)
+ of_property_read_u32(np, "tx-csum-limit", &tx_csum_limit);
+ else
+ tx_csum_limit = pd->tx_csum_limit;
+
+ msp->tx_csum_limit = tx_csum_limit ? tx_csum_limit : 9 * 1024;
infer_hw_params(msp);

platform_set_drvdata(pdev, msp);
+ ret = 0;

- return 0;
+#ifdef CONFIG_OF
+ ret = of_platform_bus_probe(np, mv643xx_eth_match, &pdev->dev);
+ if (ret)
+ goto out_free;
+#endif
+ return ret;

out_free:
kfree(msp);
@@ -2600,12 +2623,22 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
return 0;
}

+static const struct of_device_id mv643xx_eth_shared_match[] = {
+ { .compatible = "marvell,mv64360-eth-group" },
+ { .compatible = "marvell,mv64360-eth-block" },
+ { .compatible = "marvell,mv643xx-eth-group" },
+ { .compatible = "marvell,mv643xx-eth-block" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_match);
+
static struct platform_driver mv643xx_eth_shared_driver = {
.probe = mv643xx_eth_shared_probe,
.remove = mv643xx_eth_shared_remove,
.driver = {
.name = MV643XX_ETH_SHARED_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_shared_match),
},
};

@@ -2764,6 +2797,74 @@ static const struct net_device_ops mv643xx_eth_netdev_ops = {
#endif
};

+#ifdef CONFIG_OF
+static int mv643xx_eth_of_probe(struct platform_device *pdev)
+{
+ struct mv643xx_eth_platform_data *pd;
+ struct device_node *np = pdev->dev.of_node;
+ struct device_node *shared = of_get_parent(np);
+ struct device_node *phy_node;
+ const int *prop;
+ const char *mac_addr;
+
+ if (!pdev->dev.of_node)
+ return 0;
+
+ pd = kzalloc(sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return -ENOMEM;
+
+ pdev->dev.platform_data = pd;
+
+ pd->shared = of_find_device_by_node(shared);
+ if (!pd->shared)
+ return -ENODEV;
+
+ prop = of_get_property(np, "reg", NULL);
+ if (!prop)
+ return -EINVAL;
+
+ pd->port_number = be32_to_cpup(prop);
+
+ phy_node = of_parse_phandle(np, "phy", 0);
+ if (!phy_node) {
+ pd->phy_addr = MV643XX_ETH_PHY_NONE;
+
+ of_property_read_u32(np, "speed", &pd->speed);
+ of_property_read_u32(np, "duplex", &pd->duplex);
+ } else {
+ prop = of_get_property(phy_node, "reg", NULL);
+ if (prop)
+ pd->phy_addr = be32_to_cpup(prop);
+ }
+
+ mac_addr = of_get_mac_address(np);
+ if (mac_addr)
+ memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
+
+#define rx_tx_queue_sram_property(_name) \
+ prop = of_get_property(np, __stringify(_name), NULL); \
+ if (prop) \
+ pd->_name = be32_to_cpup(prop);
+
+ rx_tx_queue_sram_property(rx_queue_count);
+ rx_tx_queue_sram_property(tx_queue_count);
+ rx_tx_queue_sram_property(rx_queue_size);
+ rx_tx_queue_sram_property(tx_queue_size);
+ rx_tx_queue_sram_property(rx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+ rx_tx_queue_sram_property(tx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+
+ return 0;
+}
+#else
+static inline int mv643xx_eth_of_probe(struct platform_device *dev)
+{
+ return 0;
+}
+#endif
+
static int mv643xx_eth_probe(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *pd;
@@ -2772,7 +2873,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
struct resource *res;
int err;

+ err = mv643xx_eth_of_probe(pdev);
+ if (err)
+ return err;
+
pd = pdev->dev.platform_data;
+
if (pd == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
return -ENODEV;
@@ -2896,6 +3002,8 @@ out:
}
#endif
free_netdev(dev);
+ if (pdev->dev.of_node)
+ kfree(pd);

return err;
}
@@ -2903,6 +3011,7 @@ out:
static int mv643xx_eth_remove(struct platform_device *pdev)
{
struct mv643xx_eth_private *mp = platform_get_drvdata(pdev);
+ struct mv643xx_eth_platform_data *pd = pdev->dev.platform_data;

unregister_netdev(mp->dev);
if (mp->phy != NULL)
@@ -2918,6 +3027,9 @@ static int mv643xx_eth_remove(struct platform_device *pdev)

free_netdev(mp->dev);

+ if (pdev->dev.of_node)
+ kfree(pd);
+
platform_set_drvdata(pdev, NULL);

return 0;
@@ -2935,6 +3047,7 @@ static void mv643xx_eth_shutdown(struct platform_device *pdev)
port_reset(mp);
}

+
static struct platform_driver mv643xx_eth_driver = {
.probe = mv643xx_eth_probe,
.remove = mv643xx_eth_remove,
@@ -2942,6 +3055,7 @@ static struct platform_driver mv643xx_eth_driver = {
.driver = {
.name = MV643XX_ETH_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_match),
},
};
--
1.7.10.4
Simon Baatz
2013-04-04 21:29:06 UTC
Permalink
Hi Florian
Post by Florian Fainelli
This patch adds Device Tree bindings following the already defined
bindings at Documentation/devicetree/bindings/marvell.txt. The binding
documentation is also enhanced with new optionnal properties required
for supporting certain devices (RX/TX queue and SRAM). Since we now have
proper support for the orion MDIO bus driver, there is no need to fiddle
around with device tree phandles. PHY-less (MAC connected to switch)
configurations are supported by not specifying any phy phandle for an
ethernet node.
---
- properly ifdef of_platform_bus_probe with CONFIG_OF
- handle of_platform_bus_probe errors and cleanup accordingly
- use of_property_read_u32 where applicable
- parse "duplex" and "speed" property in PHY-less configuration
Documentation/devicetree/bindings/marvell.txt | 25 +++++-
drivers/net/ethernet/marvell/mv643xx_eth.c | 120 ++++++++++++++++++++++++-
2 files changed, 140 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt
index f1533d9..e70a013 100644
--- a/Documentation/devicetree/bindings/marvell.txt
+++ b/Documentation/devicetree/bindings/marvell.txt
@@ -112,9 +112,14 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
- #address-cells : <1>
- #size-cells : <0>
- - compatible : "marvell,mv64360-eth-block"
+ - compatible : "marvell,mv64360-eth-block", "marvell,mv64360-eth-group",
+ "marvell,mv643xx-eth-block"
- reg : Offset and length of the register set for this block
+ - tx-csum-limit : Hardware limit above which transmit checksumming
+ is disabled.
+
#address-cells = <1>;
@@ -130,7 +135,7 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
- device_type : Should be "network".
- - compatible : Should be "marvell,mv64360-eth".
+ - compatible : Should be "marvell,mv64360-eth", "marvell,mv643xx-eth".
- reg : Should be <0>, <1>, or <2>, according to which registers
within the silicon block the device uses.
- interrupts : <a> where a is the interrupt number for the port.
@@ -140,6 +145,22 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
controller.
- local-mac-address : 6 bytes, MAC address
+ - clocks : Phandle to the clock control device and gate bit
+ - clock-names : String describing the clock gate bit
+ - speed : Speed to force the link (10, 100, 1000), used when no
+ phy property is defined
+ - duplex : Duplex to force the link (0: half, 1: full), used when no
+ phy property is defined
+ - rx-queue-count : number of RX queues to use
+ - tx-queue-count : number of TX queues to use
+ - rx-queue-size : size of the RX queue (in bytes)
+ - tx-queue-size : size of the TX queue (in bytes)
+ - rx-sram-addr : address of the SRAM for RX path (non 0 means used)
+ - rx-sram-size : size of the SRAM for RX path (non 0 means used)
+ - tx-sram-addr : address of the SRAM for TX path (non 0 means used)
+ - tx-sram-size : size of the SRAM for TX path (non 0 means used)
+
device_type = "network";
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index aedbd82..75599a8 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -60,6 +60,10 @@
#include <linux/inet_lro.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/stringify.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_net.h>
static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4";
@@ -2542,14 +2546,23 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
}
}
+static const struct of_device_id mv643xx_eth_match[] = {
+ { .compatible = "marvell,mv64360-eth" },
+ { .compatible = "marvell,mv643xx-eth" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_match);
+
static int mv643xx_eth_shared_probe(struct platform_device *pdev)
{
static int mv643xx_eth_version_printed;
+ struct device_node *np = pdev->dev.of_node;
struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
struct mv643xx_eth_shared_private *msp;
const struct mbus_dram_target_info *dram;
struct resource *res;
int ret;
+ int tx_csum_limit = 0;
if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
This is not related to your change, but there is a problem in this
function that has already been discussed in the past if I remember
correctly: The respective clock needs to be enabled here (at least
on Kirkwood), since accesses to the hardware are done below.
Enabling the clock only in mv643xx_eth_probe() is too late.

As said, this is not a problem introduced by your changes (and which
is currently circumvented by enabling the respective clocks in
kirkwood_legacy_clk_init() and kirkwood_ge0x_init()), but we might
want to fix this now to get rid of unconditionally enabling the GE
clocks in the DT case.
Post by Florian Fainelli
@@ -2576,13 +2589,23 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);
- msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
- pd->tx_csum_limit : 9 * 1024;
+ if (np)
+ of_property_read_u32(np, "tx-csum-limit", &tx_csum_limit);
+ else
+ tx_csum_limit = pd->tx_csum_limit;
+
+ msp->tx_csum_limit = tx_csum_limit ? tx_csum_limit : 9 * 1024;
infer_hw_params(msp);
platform_set_drvdata(pdev, msp);
+ ret = 0;
- return 0;
+#ifdef CONFIG_OF
+ ret = of_platform_bus_probe(np, mv643xx_eth_match, &pdev->dev);
+ if (ret)
+ goto out_free;
+#endif
+ return ret;
kfree(msp);
@@ -2600,12 +2623,22 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id mv643xx_eth_shared_match[] = {
+ { .compatible = "marvell,mv64360-eth-group" },
+ { .compatible = "marvell,mv64360-eth-block" },
+ { .compatible = "marvell,mv643xx-eth-group" },
+ { .compatible = "marvell,mv643xx-eth-block" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_match);
+
static struct platform_driver mv643xx_eth_shared_driver = {
.probe = mv643xx_eth_shared_probe,
.remove = mv643xx_eth_shared_remove,
.driver = {
.name = MV643XX_ETH_SHARED_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_shared_match),
},
};
@@ -2764,6 +2797,74 @@ static const struct net_device_ops mv643xx_eth_netdev_ops = {
#endif
};
+#ifdef CONFIG_OF
+static int mv643xx_eth_of_probe(struct platform_device *pdev)
+{
+ struct mv643xx_eth_platform_data *pd;
+ struct device_node *np = pdev->dev.of_node;
+ struct device_node *shared = of_get_parent(np);
+ struct device_node *phy_node;
+ const int *prop;
+ const char *mac_addr;
+
+ if (!pdev->dev.of_node)
+ return 0;
+
+ pd = kzalloc(sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return -ENOMEM;
+
+ pdev->dev.platform_data = pd;
+
+ pd->shared = of_find_device_by_node(shared);
+ if (!pd->shared)
+ return -ENODEV;
+
+ prop = of_get_property(np, "reg", NULL);
+ if (!prop)
+ return -EINVAL;
+
+ pd->port_number = be32_to_cpup(prop);
+
+ phy_node = of_parse_phandle(np, "phy", 0);
+ if (!phy_node) {
+ pd->phy_addr = MV643XX_ETH_PHY_NONE;
+
+ of_property_read_u32(np, "speed", &pd->speed);
+ of_property_read_u32(np, "duplex", &pd->duplex);
+ } else {
+ prop = of_get_property(phy_node, "reg", NULL);
+ if (prop)
+ pd->phy_addr = be32_to_cpup(prop);
+ }
+
+ mac_addr = of_get_mac_address(np);
+ if (mac_addr)
+ memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
+
+#define rx_tx_queue_sram_property(_name) \
+ prop = of_get_property(np, __stringify(_name), NULL); \
+ if (prop) \
+ pd->_name = be32_to_cpup(prop);
+
+ rx_tx_queue_sram_property(rx_queue_count);
+ rx_tx_queue_sram_property(tx_queue_count);
+ rx_tx_queue_sram_property(rx_queue_size);
+ rx_tx_queue_sram_property(tx_queue_size);
+ rx_tx_queue_sram_property(rx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+ rx_tx_queue_sram_property(tx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+
+ return 0;
+}
+#else
+static inline int mv643xx_eth_of_probe(struct platform_device *dev)
+{
+ return 0;
+}
+#endif
+
static int mv643xx_eth_probe(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *pd;
@@ -2772,7 +2873,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
struct resource *res;
int err;
+ err = mv643xx_eth_of_probe(pdev);
+ if (err)
+ return err;
+
pd = pdev->dev.platform_data;
+
if (pd == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
return -ENODEV;
You don't change the clk initialization here:

#if defined(CONFIG_HAVE_CLK)
mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0"));
if (!IS_ERR(mp->clk)) {
clk_prepare_enable(mp->clk);
mp->t_clk = clk_get_rate(mp->clk);
}
#endif

Which, if I understand correctly, works in the DT case because you
assign "clock-names" to the clocks in the DTS. However, I wonder
whether this works for any but the first Ethernet device.

In the old platform device setup, the pdev->id was set when
initialiazing the platform_device structure in common.c. Where is
this done in the DT case?


In phy_scan(), the phy is searched like this:

snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
"orion-mdio-mii", addr);

phydev = phy_connect(mp->dev, phy_id, mv643xx_eth_adjust_link,
PHY_INTERFACE_MODE_GMII);

But "orion-mdio-mii:xx" is the name of the PHY if MDIO is setup via a
platform_device. I could not get this to work if the MDIO device is
setup via DT. Am I doing something wrong?


Additionally, in phy_scan() there is this:

if (phy_addr == MV643XX_ETH_PHY_ADDR_DEFAULT) {
start = phy_addr_get(mp) & 0x1f;
num = 32;
} else {
...

MV643XX_ETH_PHY_ADDR_DEFAULT is defined as 0. However, many Kirkwood
devices use "MV643XX_ETH_PHY_ADDR(0)". If the module probe is
deferred in mv643xx_eth because the MDIO driver is not yet loaded,
all 32 PHY addresses are scanned without success. This is not needed
and clutters the log.


- Simon
Sebastian Hesselbarth
2013-04-05 13:58:03 UTC
Permalink
[snip]
Florian,

took me a while to try you patches out on Dove but now I fixed all
issues. I will
comment on all related patches but first I want to comment here.

One general note for Dove related patches: You didn't remove the registration of
ge platform_device from mach-dove/board-dt.c. That will lead to double
registration
of mdio and mv643xx_eth/shared, so you'll never be sure if DT or non-DT code is
executed. I haven't checked mach-kirkwood/board-dt.c or orion5x code.
Post by Simon Baatz
Post by Florian Fainelli
if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
This is not related to your change, but there is a problem in this
function that has already been discussed in the past if I remember
correctly: The respective clock needs to be enabled here (at least
on Kirkwood), since accesses to the hardware are done below.
Enabling the clock only in mv643xx_eth_probe() is too late.
As said, this is not a problem introduced by your changes (and which
is currently circumvented by enabling the respective clocks in
kirkwood_legacy_clk_init() and kirkwood_ge0x_init()), but we might
want to fix this now to get rid of unconditionally enabling the GE
clocks in the DT case.
I think there may have been some confusion between the "ethernet-group"
clock and the actual Ethernet port inside the "ethernet-group". The
mv643xx_eth driver assumes we have a per-port clock gating scheme, while I
think we have a per "ethernet-group" clock gating scheme instead. Like you
said, I think this should be addressed separately.
IMHO, there should be a clocks property where ever you try to access registers,
i.e. in all three "parts" mv643xx_eth_shared (group), mv643xx_eth
(port) and mdio.
Since port depends on shared it would be ok to have it per group but that may
collide with other SoCs than Dove/Kirkwood that have per port clocks.

Is that separation (group/port) really required for any SoC?
[snip]
Post by Simon Baatz
#if defined(CONFIG_HAVE_CLK)
mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0"));
if (!IS_ERR(mp->clk)) {
clk_prepare_enable(mp->clk);
mp->t_clk = clk_get_rate(mp->clk);
}
#endif
Which, if I understand correctly, works in the DT case because you
assign "clock-names" to the clocks in the DTS. However, I wonder
whether this works for any but the first Ethernet device.
Yes, it does. Assigned clocks from clocks property get a clock alias for
that device name (node name). Using anything else than NULL here is
IMHO just wrong. We should rather provide proper clock aliases for non-DT case.
Post by Simon Baatz
In the old platform device setup, the pdev->id was set when
initialiazing the platform_device structure in common.c. Where is
this done in the DT case?
Looks like you are right, in the DT case, I assume that we should lookup the
clock using NULL instead of "1" or "0" so we match any clock instead of a
specific one.
Yes.
[snip]
Post by Simon Baatz
snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
"orion-mdio-mii", addr);
phydev = phy_connect(mp->dev, phy_id,
mv643xx_eth_adjust_link,
PHY_INTERFACE_MODE_GMII);
But "orion-mdio-mii:xx" is the name of the PHY if MDIO is setup via a
platform_device. I could not get this to work if the MDIO device is
setup via DT. Am I doing something wrong?
I just missed updating this part of the code to probe for PHYs. The board I
tested with uses a "PHY_NONE" configuration. I will add the missing bits for
of_phy_connect() to be called here.
I don't think that the ethernet controller should probe the PHY's on mdio-bus
at all. At least not for DT enabled platforms. I had a look at DT and non-DT
mdio-bus sources, and realized that there is a bus scan for non-DT only.
of_mdiobus_register requires you to set (and know) the PHY address.

I prepared a patch for of_mdio_register that will allow you to probe mdio and
assign phy addresses to each node found. Currently, the heuristic for probing
is: assign each phy node the next probed phy_addr starting with 0. But that
will not allow to e.g. set some PHY addresses and probe the rest.

We had a similar discussion whether to probe or not for DT nodes, and I guess
there also will be some discussion about the above patch. OTOH we could just
(again) ask users of every kirkwood/orion5x/dove board to tell their
phy addresses
and fail to probe the phy for new boards...

I will prepare a proper patch soon and post it on the corresponding lists.
Post by Simon Baatz
if (phy_addr == MV643XX_ETH_PHY_ADDR_DEFAULT) {
start = phy_addr_get(mp) & 0x1f;
num = 32;
} else {
...
MV643XX_ETH_PHY_ADDR_DEFAULT is defined as 0. However, many Kirkwood
devices use "MV643XX_ETH_PHY_ADDR(0)". If the module probe is
deferred in mv643xx_eth because the MDIO driver is not yet loaded,
all 32 PHY addresses are scanned without success. This is not needed
and clutters the log.
Ok, I am not sure how we can circumvent the log cluttering that happens,
what would be your suggestion?
My suggestion is to change MV643XX_ETH_PHY_ADDR_DEFAULT from a valid
phy address (0)
to something invalid (32). I understand that using 0 helps if you
don't want to set it in mv643xx's platform_data
but it is always difficult to rely on that if 0 is a valid number.

Changing the above to 32 should just work because most (all?) boards
using phy_scan should also
already use MV643XX_ETH_PHY_ADDR_DEFAULT. I also suggest to rename
current define to a
better name, e.g. MV643XX_ETH_PHY_ADDR_AUTOSCAN.

Sebastian
Florian Fainelli
2013-04-05 14:23:17 UTC
Permalink
Hello Sebastian,
Post by Simon Baatz
[snip]
Florian,
took me a while to try you patches out on Dove but now I fixed all
issues. I will
comment on all related patches but first I want to comment here.
One general note for Dove related patches: You didn't remove the registration of
ge platform_device from mach-dove/board-dt.c. That will lead to double
registration
of mdio and mv643xx_eth/shared, so you'll never be sure if DT or non-DT code is
executed. I haven't checked mach-kirkwood/board-dt.c or orion5x code.
This was intentional, this patchset is just preparatory in the sense
that it does no conversion of the existing users of the mv643xx_eth
platform driver over DT (have some patches to that though). I wanted to
resume the discussion on these bindings first, then proceed with the
conversion.
Post by Simon Baatz
Post by Simon Baatz
Post by Florian Fainelli
if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
This is not related to your change, but there is a problem in this
function that has already been discussed in the past if I remember
correctly: The respective clock needs to be enabled here (at least
on Kirkwood), since accesses to the hardware are done below.
Enabling the clock only in mv643xx_eth_probe() is too late.
As said, this is not a problem introduced by your changes (and which
is currently circumvented by enabling the respective clocks in
kirkwood_legacy_clk_init() and kirkwood_ge0x_init()), but we might
want to fix this now to get rid of unconditionally enabling the GE
clocks in the DT case.
I think there may have been some confusion between the "ethernet-group"
clock and the actual Ethernet port inside the "ethernet-group". The
mv643xx_eth driver assumes we have a per-port clock gating scheme, while I
think we have a per "ethernet-group" clock gating scheme instead. Like you
said, I think this should be addressed separately.
IMHO, there should be a clocks property where ever you try to access registers,
i.e. in all three "parts" mv643xx_eth_shared (group), mv643xx_eth
(port) and mdio.
Since port depends on shared it would be ok to have it per group but that may
collide with other SoCs than Dove/Kirkwood that have per port clocks.
Ok, which means that we should also teach mv643xx_eth_shared_probe()
about it, as well as the orion-mdio driver. I don't have any particular
objections since it should just make things safer with respect to clocking.
Post by Simon Baatz
Is that separation (group/port) really required for any SoC?
Probably not, it was not clear when I looked at mv78xx0 if it uses two
ports per group or 4 groups and 1 port. Anyway, since we are re-using
the existing Device Tree binding definition and that the hardware
present itself as ethernet groups and ports, I don't see any problem
with keeping that difference since it allows for fine-grained
representation of the hardware.
Post by Simon Baatz
[snip]
Post by Simon Baatz
#if defined(CONFIG_HAVE_CLK)
mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0"));
if (!IS_ERR(mp->clk)) {
clk_prepare_enable(mp->clk);
mp->t_clk = clk_get_rate(mp->clk);
}
#endif
Which, if I understand correctly, works in the DT case because you
assign "clock-names" to the clocks in the DTS. However, I wonder
whether this works for any but the first Ethernet device.
Yes, it does. Assigned clocks from clocks property get a clock alias for
that device name (node name). Using anything else than NULL here is
IMHO just wrong. We should rather provide proper clock aliases for non-DT case.
Post by Simon Baatz
In the old platform device setup, the pdev->id was set when
initialiazing the platform_device structure in common.c. Where is
this done in the DT case?
Looks like you are right, in the DT case, I assume that we should lookup the
clock using NULL instead of "1" or "0" so we match any clock instead of a
specific one.
Yes.
[snip]
Post by Simon Baatz
snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
"orion-mdio-mii", addr);
phydev = phy_connect(mp->dev, phy_id,
mv643xx_eth_adjust_link,
PHY_INTERFACE_MODE_GMII);
But "orion-mdio-mii:xx" is the name of the PHY if MDIO is setup via a
platform_device. I could not get this to work if the MDIO device is
setup via DT. Am I doing something wrong?
I just missed updating this part of the code to probe for PHYs. The board I
tested with uses a "PHY_NONE" configuration. I will add the missing bits for
of_phy_connect() to be called here.
I don't think that the ethernet controller should probe the PHY's on mdio-bus
at all. At least not for DT enabled platforms. I had a look at DT and non-DT
mdio-bus sources, and realized that there is a bus scan for non-DT only.
of_mdiobus_register requires you to set (and know) the PHY address.
One reason the Ethernet controller could do the probing is in the case
we need to apply quirks (e.g: using phydev->flags) for instance. This
can be done even after the MDIO bus driver did probe PHY devices though.
Post by Simon Baatz
I prepared a patch for of_mdio_register that will allow you to probe mdio and
assign phy addresses to each node found. Currently, the heuristic for probing
is: assign each phy node the next probed phy_addr starting with 0. But that
will not allow to e.g. set some PHY addresses and probe the rest.
Ok, we just need to make sure that this does not break any specific use
case, I don't think it does, since it seems to be more accurate or
equivalent to Ethernet driver doing the probing.
Post by Simon Baatz
We had a similar discussion whether to probe or not for DT nodes, and I guess
there also will be some discussion about the above patch. OTOH we could just
(again) ask users of every kirkwood/orion5x/dove board to tell their
phy addresses
and fail to probe the phy for new boards...
I will prepare a proper patch soon and post it on the corresponding lists.
Cool, thanks!
Post by Simon Baatz
Post by Simon Baatz
if (phy_addr == MV643XX_ETH_PHY_ADDR_DEFAULT) {
start = phy_addr_get(mp) & 0x1f;
num = 32;
} else {
...
MV643XX_ETH_PHY_ADDR_DEFAULT is defined as 0. However, many Kirkwood
devices use "MV643XX_ETH_PHY_ADDR(0)". If the module probe is
deferred in mv643xx_eth because the MDIO driver is not yet loaded,
all 32 PHY addresses are scanned without success. This is not needed
and clutters the log.
Ok, I am not sure how we can circumvent the log cluttering that happens,
what would be your suggestion?
My suggestion is to change MV643XX_ETH_PHY_ADDR_DEFAULT from a valid
phy address (0)
to something invalid (32). I understand that using 0 helps if you
don't want to set it in mv643xx's platform_data
but it is always difficult to rely on that if 0 is a valid number.
Changing the above to 32 should just work because most (all?) boards
using phy_scan should also
already use MV643XX_ETH_PHY_ADDR_DEFAULT. I also suggest to rename
current define to a
better name, e.g. MV643XX_ETH_PHY_ADDR_AUTOSCAN.
Sounds good to me.
--
Florian
Sebastian Hesselbarth
2013-04-05 20:35:41 UTC
Permalink
Post by Sebastian Hesselbarth
I don't think that the ethernet controller should probe the PHY's on mdio-bus
at all. At least not for DT enabled platforms. I had a look at DT and non-DT
mdio-bus sources, and realized that there is a bus scan for non-DT only.
of_mdiobus_register requires you to set (and know) the PHY address.
DT platforms should have the option to use the standard phy-phandle
#address-cells =<1>;
#size-cells =<0>;
compatible = "marvell,orion-mdio";
reg =<0x72004 0x84>;
status = "disabled";
+ reg =<1>;
+ device_type = "ethernet-phy";
+ };
};
#address-cells =<1>;
#size-cells =<0>;
compatible = "marvell,mv643xx-eth-block";
reg =<0x72000 0x4000>;
tx-csum-limit =<1600>;
status = "disabled";
device_type = "network";
compatible = "marvell,mv643xx-eth";
reg =<0>;
interrupts =<29>;
clocks =<&gate_clk 2>;
+ phy-handle =<&PHY1>;
};
};
When phy-handle is present the ethernet driver should not probe/scan for
phys.
There is standard code to handle all of this - an important gain is
that the phy driver now has access to a DT node and can apply
phy-specific properties.
The above is what I use as a modification of Florian's patches.
I compared of_mdiobus_register against mdiobus_register. The difference
is that DT version does not scan the bus for attached PHYs. That is ok,
if you know the phy_address of the PHY that you pass the handle of. But
in most cases there will be only one PHY on the mdiobus and especially
for new boards probing will help here.
Post by Sebastian Hesselbarth
We had a similar discussion whether to probe or not for DT nodes,
and I guess there also will be some discussion about the above
patch. OTOH we could just (again) ask users of every
kirkwood/orion5x/dove board to tell their phy addresses and fail to
probe the phy for new boards...
Maybe print a warning and call the no-DT phy probe code if phy-handle
is nor present?
I think it would be best to spam each probing result during mdiobus
scan to encourage people to edit the DT and put in the phy_addr
directly. IMHO it will be best to have bus scan on mdiobus rather than
ethernet driver.
Not sure this should be in the common code, phy probing is sketchy, it
shouldn't be encouraged, IMHO..
Actually, it is in common code (non-DT case) and I think passing the
phy_addr by DT node like above is best. But for boards you don't
know the address (yet) probing helps a lot. If all phy nodes have their
reg property set, no probing will be performed.

For testing mdio bus probe, I used

mdio {
...
ethphy: ethernet-phy {
reg = <32>;
};
};

And 32 should be defined as OF_PHY_ADDR_AUTOSCAN. It is an invalid
address as max phy_addr is 31. I also thought about a bool property
but passing an invalid reg property in SoC file allows to overwrite
it in board file with the actual address easily.
And AFAIK bool properties cannot be removed later on by board specific
nodes.

Sebastian
Jason Gunthorpe
2013-04-05 18:04:43 UTC
Permalink
Post by Sebastian Hesselbarth
I don't think that the ethernet controller should probe the PHY's on mdio-bus
at all. At least not for DT enabled platforms. I had a look at DT and non-DT
mdio-bus sources, and realized that there is a bus scan for non-DT only.
of_mdiobus_register requires you to set (and know) the PHY address.
DT platforms should have the option to use the standard phy-phandle
connection:


***@72004 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "marvell,orion-mdio";
reg = <0x72004 0x84>;
status = "disabled";

+ PHY1: ethernet-***@1 {
+ reg = <1>;
+ device_type = "ethernet-phy";
+ };
};

ethernet-***@72000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "marvell,mv643xx-eth-block";
reg = <0x72000 0x4000>;
tx-csum-limit = <1600>;
status = "disabled";

egiga0: ***@0 {
device_type = "network";
compatible = "marvell,mv643xx-eth";
reg = <0>;
interrupts = <29>;
clocks = <&gate_clk 2>;
+ phy-handle = <&PHY1>;
};
};

When phy-handle is present the ethernet driver should not probe/scan for
phys.

There is standard code to handle all of this - an important gain is
that the phy driver now has access to a DT node and can apply
phy-specific properties.
Post by Sebastian Hesselbarth
We had a similar discussion whether to probe or not for DT nodes,
and I guess there also will be some discussion about the above
patch. OTOH we could just (again) ask users of every
kirkwood/orion5x/dove board to tell their phy addresses and fail to
probe the phy for new boards...
Maybe print a warning and call the no-DT phy probe code if phy-handle
is nor present?

Not sure this should be in the common code, phy probing is sketchy, it
shouldn't be encouraged, IMHO..

Jason
Florian Fainelli
2013-04-05 09:56:48 UTC
Permalink
Hello Simon,

First of all, thanks for getting these patches a try!
Post by Simon Baatz
Hi Florian
[snip]
Post by Simon Baatz
Post by Florian Fainelli
if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
This is not related to your change, but there is a problem in this
function that has already been discussed in the past if I remember
correctly: The respective clock needs to be enabled here (at least
on Kirkwood), since accesses to the hardware are done below.
Enabling the clock only in mv643xx_eth_probe() is too late.
As said, this is not a problem introduced by your changes (and which
is currently circumvented by enabling the respective clocks in
kirkwood_legacy_clk_init() and kirkwood_ge0x_init()), but we might
want to fix this now to get rid of unconditionally enabling the GE
clocks in the DT case.
I think there may have been some confusion between the "ethernet-group"
clock and the actual Ethernet port inside the "ethernet-group". The
mv643xx_eth driver assumes we have a per-port clock gating scheme, while
I think we have a per "ethernet-group" clock gating scheme instead. Like
you said, I think this should be addressed separately.

[snip]
Post by Simon Baatz
#if defined(CONFIG_HAVE_CLK)
mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0"));
if (!IS_ERR(mp->clk)) {
clk_prepare_enable(mp->clk);
mp->t_clk = clk_get_rate(mp->clk);
}
#endif
Which, if I understand correctly, works in the DT case because you
assign "clock-names" to the clocks in the DTS. However, I wonder
whether this works for any but the first Ethernet device.
In the old platform device setup, the pdev->id was set when
initialiazing the platform_device structure in common.c. Where is
this done in the DT case?
Looks like you are right, in the DT case, I assume that we should lookup
the clock using NULL instead of "1" or "0" so we match any clock instead
of a specific one.

[snip]
Post by Simon Baatz
snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
"orion-mdio-mii", addr);
phydev = phy_connect(mp->dev, phy_id, mv643xx_eth_adjust_link,
PHY_INTERFACE_MODE_GMII);
But "orion-mdio-mii:xx" is the name of the PHY if MDIO is setup via a
platform_device. I could not get this to work if the MDIO device is
setup via DT. Am I doing something wrong?
I just missed updating this part of the code to probe for PHYs. The
board I tested with uses a "PHY_NONE" configuration. I will add the
missing bits for of_phy_connect() to be called here.
Post by Simon Baatz
if (phy_addr == MV643XX_ETH_PHY_ADDR_DEFAULT) {
start = phy_addr_get(mp) & 0x1f;
num = 32;
} else {
...
MV643XX_ETH_PHY_ADDR_DEFAULT is defined as 0. However, many Kirkwood
devices use "MV643XX_ETH_PHY_ADDR(0)". If the module probe is
deferred in mv643xx_eth because the MDIO driver is not yet loaded,
all 32 PHY addresses are scanned without success. This is not needed
and clutters the log.
Ok, I am not sure how we can circumvent the log cluttering that happens,
what would be your suggestion?
--
Florian
Jason Cooper
2013-04-11 16:53:03 UTC
Permalink
Florian,
Hi all,
This patch serie implements mv643xx_eth device tree bindings. I opted for
the reuse of the bindings already defined in
Documentation/devicetree/bindings/marvell.txt so that we do not create
any confusion.
For reference, I have included the mv643xx-eth related nodes in the
corresponding Kirkwood, Dove and Orion5x .dtsi files so you can more
easily test on your own platforms.
I tested these on a custom 88F6181-based boards.
mv643xx_eth: add Device Tree bindings
mv643xx_eth: update Device Tree bindings documentation
ARM: kirkwood: add device node entries for the gigabit interfaces
ARM: orion5x: add gigabit ethernet device tree node
ARM: dove: add gigabit device tree nodes to dove.dtsi
Documentation/devicetree/bindings/marvell.txt | 25 +++++-
arch/arm/boot/dts/dove.dtsi | 25 ++++++
arch/arm/boot/dts/kirkwood.dtsi | 46 ++++++++++
arch/arm/boot/dts/orion5x.dtsi | 23 +++++
drivers/net/ethernet/marvell/mv643xx_eth.c | 120 ++++++++++++++++++++++++-
5 files changed, 234 insertions(+), 5 deletions(-)
How is the new version of this looking? Do you think you'll be able to
get it up in time for DaveM to take it into v3.10?

With this and Thomas' pci series, we will have Kirkwood fully converted
to devicetree, can begin removing board files, and finally begin
migrating everything over to mach-mvebu/. This will lead to the removal
of five directories under arch/arm/ (plat-orion, mach-kirkwood,
mach-orion5x, mach-dove, and mach-mv78xx0).

thx,

Jason.
Sebastian Hesselbarth
2013-04-11 17:09:54 UTC
Permalink
Post by Jason Cooper
This patch serie implements mv643xx_eth device tree bindings. I opted for
the reuse of the bindings already defined in
Documentation/devicetree/bindings/marvell.txt so that we do not create
any confusion.
How is the new version of this looking? Do you think you'll be able to
get it up in time for DaveM to take it into v3.10?
With this and Thomas' pci series, we will have Kirkwood fully converted
to devicetree, can begin removing board files, and finally begin
migrating everything over to mach-mvebu/. This will lead to the removal
of five directories under arch/arm/ (plat-orion, mach-kirkwood,
mach-orion5x, mach-dove, and mach-mv78xx0).
Jason,

I sent Florian an update of some of his patches earlier, based on
cleanup patches I submitted for mv643xx_eth while testing his patch set.
I think, the patch set will play nicely on ARM but without PPC guys involved
in testing it, I guess it will break something there.

Florian is reusing the DT bindings from PPC and they are compatible, but
there parsing is also done within arch/ppc/sysdev/mv64360-dev.c and
maybe somewhere else. The current DT patches for mv643xx_eth will
reparse some properties again (and may break eth on ppc platforms
using mv643xx_eth).

Sebastian
Thomas Petazzoni
2013-04-13 15:21:26 UTC
Permalink
Dear Jason Cooper,
Post by Jason Cooper
With this and Thomas' pci series, we will have Kirkwood fully
converted to devicetree, can begin removing board files, and finally
begin migrating everything over to mach-mvebu/. This will lead to
the removal of five directories under arch/arm/ (plat-orion,
mach-kirkwood, mach-orion5x, mach-dove, and mach-mv78xx0).
No, we can't remove mach-orion5x and mach-mv78xx0 for now, they have
not been converted at all in terms of gpio/pinmux support. I've started
writing some pinmux code for orion5x but it's not ready.

I don't think we should rush in doing this merge into mach-mvebu. I'd
prefer to have the following conditions be met before a platform gets
merged into mach-mvebu:

* The mach-<foo> directory no longer depends on anything in
plat-orion. For mach-kirkwood, things are OK (for the DT platforms)
for GPIO, MPP and PCIe, but some work remains for the IRQ controller
driver and the timer driver.

* All boards have been converted to the Device Tree. For
mach-kirkwood, we're getting closer.

Once a given mach-<foo> platform meets these conditions, it will be a
clean platform, and we can merge it into mach-mvebu without any
problem.

So let's continue the cleanup work, conversion to DT, usage of drivers
in drivers/, improvement of pinmux to support orion5x/mv78xx0, and do
the move per-platform, once they are ready.

What do you think?

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
Jason Cooper
2013-04-13 19:00:37 UTC
Permalink
Post by Thomas Petazzoni
Dear Jason Cooper,
Post by Jason Cooper
With this and Thomas' pci series, we will have Kirkwood fully
converted to devicetree, can begin removing board files, and finally
begin migrating everything over to mach-mvebu/. This will lead to
the removal of five directories under arch/arm/ (plat-orion,
mach-kirkwood, mach-orion5x, mach-dove, and mach-mv78xx0).
No, we can't remove mach-orion5x and mach-mv78xx0 for now, they have
not been converted at all in terms of gpio/pinmux support. I've started
writing some pinmux code for orion5x but it's not ready.
I don't think we should rush in doing this merge into mach-mvebu. I'd
prefer to have the following conditions be met before a platform gets
* The mach-<foo> directory no longer depends on anything in
plat-orion. For mach-kirkwood, things are OK (for the DT platforms)
for GPIO, MPP and PCIe, but some work remains for the IRQ controller
driver and the timer driver.
* All boards have been converted to the Device Tree. For
mach-kirkwood, we're getting closer.
Once a given mach-<foo> platform meets these conditions, it will be a
clean platform, and we can merge it into mach-mvebu without any
problem.
So let's continue the cleanup work, conversion to DT, usage of drivers
in drivers/, improvement of pinmux to support orion5x/mv78xx0, and do
the move per-platform, once they are ready.
What do you think?
I agree completely. I was simply restating the longview goal of the
work we are doing (above and beyond adding armadaXP/370). I probably
should have given a time reference for "This will lead to..." :)

Also, I have a feeling that not all legacy boards will get converted
over. If there is no interest or no way to test, certains boards may
get deprecated.

thx,

Jason.
Ben Hutchings
2013-04-15 03:07:14 UTC
Permalink
Post by Jason Cooper
Post by Thomas Petazzoni
Dear Jason Cooper,
Post by Jason Cooper
With this and Thomas' pci series, we will have Kirkwood fully
converted to devicetree, can begin removing board files, and finally
begin migrating everything over to mach-mvebu/. This will lead to
the removal of five directories under arch/arm/ (plat-orion,
mach-kirkwood, mach-orion5x, mach-dove, and mach-mv78xx0).
No, we can't remove mach-orion5x and mach-mv78xx0 for now, they have
not been converted at all in terms of gpio/pinmux support. I've started
writing some pinmux code for orion5x but it's not ready.
[...]
Post by Jason Cooper
Also, I have a feeling that not all legacy boards will get converted
over. If there is no interest or no way to test, certains boards may
get deprecated.
Debian supports many Kirkwood and Orion 5x systems. A call for testing
on the debian-***@lists.debian.org list might be worthwhile.

I would be very glad to see kirkwood, orion5x and mv78xx0 merged - we
build natively and this takes about 8 hours for each configuration.

Ben.
--
Ben Hutchings
The first rule of tautology club is the first rule of tautology club.
Jason Cooper
2013-04-15 13:43:25 UTC
Permalink
Post by Ben Hutchings
Post by Jason Cooper
Post by Thomas Petazzoni
Dear Jason Cooper,
Post by Jason Cooper
With this and Thomas' pci series, we will have Kirkwood fully
converted to devicetree, can begin removing board files, and finally
begin migrating everything over to mach-mvebu/. This will lead to
the removal of five directories under arch/arm/ (plat-orion,
mach-kirkwood, mach-orion5x, mach-dove, and mach-mv78xx0).
No, we can't remove mach-orion5x and mach-mv78xx0 for now, they have
not been converted at all in terms of gpio/pinmux support. I've started
writing some pinmux code for orion5x but it's not ready.
[...]
Post by Jason Cooper
Also, I have a feeling that not all legacy boards will get converted
over. If there is no interest or no way to test, certains boards may
get deprecated.
Debian supports many Kirkwood and Orion 5x systems. A call for testing
definitely.
Post by Ben Hutchings
I would be very glad to see kirkwood, orion5x and mv78xx0 merged - we
build natively and this takes about 8 hours for each configuration.
That's the plan, build an armv5 kernel, and dtb's for all the boards.
Then, an armv7 kernel for the armadaXP/370 boards, etc.

thx,

Jason.
Thomas Petazzoni
2013-04-15 10:00:11 UTC
Permalink
Dear Jason Cooper,
Post by Jason Cooper
Post by Thomas Petazzoni
So let's continue the cleanup work, conversion to DT, usage of
drivers in drivers/, improvement of pinmux to support
orion5x/mv78xx0, and do the move per-platform, once they are ready.
What do you think?
I agree completely. I was simply restating the longview goal of the
work we are doing (above and beyond adding armadaXP/370). I probably
should have given a time reference for "This will lead to..." :)
Ok. I definitely agree with the long-term goal.
Post by Jason Cooper
Also, I have a feeling that not all legacy boards will get converted
over. If there is no interest or no way to test, certains boards may
get deprecated.
I think for many of them, we can do a 'blind' conversion to DT, and ask
the users who have posted patches or even submitted support for those
boards to test the DT. But I don't think we should move things into
mach-mvebu if there are still legacy non-DT Kirkwood platforms
supported in mach-kirkwood. So either we convert them to the DT, or we
remove the support for them if no-one is really interested. But I
believe in most cases, converting them to DT should be quite easy.

Best regards,

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
Sebastian Hesselbarth
2013-05-06 15:33:33 UTC
Permalink
This patch set picks up work by Florian Fainelli bringing full DT
support to mv643xx_eth and Marvell SoCs using it.

The current patch set drops Florian's device tree conversions for
Kirkwood, Dove, and Orion5x in favour of split patches for board
files and board descriptor files.

Device tree conversion for Dove and Kirkwood is added. Dove has
been fully tested, while Kirkwood is compile-tested only.

Florian Fainelli (2):
net: mv643xx_eth: add Device Tree bindings
net: mv643xx_eth: update Device Tree bindings documentation

Sebastian Hesselbarth (5):
ARM: dove: remove legacy mv643xx_eth setup
ARM: dove: add gigabit ethernet and mvmdio device tree nodes
ARM: kirkwood: remove legacy mv643xx_eth board setup
ARM: kirkwood: add gigabit ethernet and mvmdio device tree nodes
ARM: kirkwood: remove legacy clk alias for mv643xx_eth

Documentation/devicetree/bindings/marvell.txt | 22 ++++-
arch/arm/boot/dts/dove-cubox.dts | 8 ++
arch/arm/boot/dts/dove.dtsi | 35 +++++++
arch/arm/boot/dts/kirkwood-cloudbox.dts | 15 +++
arch/arm/boot/dts/kirkwood-dnskw.dtsi | 15 +++
arch/arm/boot/dts/kirkwood-dockstar.dts | 15 +++
arch/arm/boot/dts/kirkwood-dreamplug.dts | 26 +++++
arch/arm/boot/dts/kirkwood-goflexnet.dts | 15 +++
.../arm/boot/dts/kirkwood-guruplug-server-plus.dts | 26 +++++
arch/arm/boot/dts/kirkwood-ib62x0.dts | 15 +++
arch/arm/boot/dts/kirkwood-iconnect.dts | 15 +++
arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts | 22 ++++
arch/arm/boot/dts/kirkwood-is2.dts | 2 +
arch/arm/boot/dts/kirkwood-km_kirkwood.dts | 15 +++
arch/arm/boot/dts/kirkwood-lsxl.dtsi | 26 +++++
arch/arm/boot/dts/kirkwood-mplcec4.dts | 25 +++++
.../boot/dts/kirkwood-netgear_readynas_duo_v2.dts | 15 +++
arch/arm/boot/dts/kirkwood-ns2-common.dtsi | 15 +++
arch/arm/boot/dts/kirkwood-ns2.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2lite.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2max.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2mini.dts | 2 +
arch/arm/boot/dts/kirkwood-openblocks_a6.dts | 15 +++
arch/arm/boot/dts/kirkwood-topkick.dts | 15 +++
arch/arm/boot/dts/kirkwood-ts219-6281.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219-6282.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219.dtsi | 15 +++
arch/arm/boot/dts/kirkwood.dtsi | 52 ++++++++++
arch/arm/mach-dove/board-dt.c | 5 -
arch/arm/mach-kirkwood/board-dnskw.c | 7 --
arch/arm/mach-kirkwood/board-dockstar.c | 9 --
arch/arm/mach-kirkwood/board-dreamplug.c | 14 ---
arch/arm/mach-kirkwood/board-dt.c | 16 ---
arch/arm/mach-kirkwood/board-goflexnet.c | 9 --
arch/arm/mach-kirkwood/board-guruplug.c | 14 ---
arch/arm/mach-kirkwood/board-ib62x0.c | 9 --
arch/arm/mach-kirkwood/board-iconnect.c | 6 -
arch/arm/mach-kirkwood/board-iomega_ix2_200.c | 16 ---
arch/arm/mach-kirkwood/board-km_kirkwood.c | 7 --
arch/arm/mach-kirkwood/board-lsxl.c | 12 --
arch/arm/mach-kirkwood/board-mplcec4.c | 11 --
arch/arm/mach-kirkwood/board-ns2.c | 13 ---
arch/arm/mach-kirkwood/board-openblocks_a6.c | 9 --
arch/arm/mach-kirkwood/board-readynas.c | 6 -
arch/arm/mach-kirkwood/board-ts219.c | 13 ---
arch/arm/mach-kirkwood/board-usi_topkick.c | 9 --
drivers/net/ethernet/marvell/mv643xx_eth.c | 108 +++++++++++++++++++-
include/linux/mv643xx_eth.h | 3 +
48 files changed, 544 insertions(+), 192 deletions(-)
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
--
1.7.2.5
Sebastian Hesselbarth
2013-05-06 15:33:34 UTC
Permalink
From: Florian Fainelli <florian-***@public.gmane.org>

This patch adds Device Tree bindings following the already defined
bindings at Documentation/devicetree/bindings/marvell.txt. The binding
documentation is also enhanced with new optionnal properties required
for supporting certain devices (RX/TX queue and SRAM). Since we now have
proper support for the orion MDIO bus driver, there is no need to fiddle
around with device tree phandles. PHY-less (MAC connected to switch)
configurations are supported by not specifying any phy phandle for an
ethernet node.

Signed-off-by: Florian Fainelli <florian-***@public.gmane.org>
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-***@public.gmane.org>
---
Changelog:
v2->v3:
- rebase on top of mv643xx_eth clean-ups
- do not reparse existing platform_data
- use managed devm_kzalloc for parsed platform_data
- use of_property_read_u32 where applicable
- add phy_node to platform_data
- use of_connect_phy if DT phy node was found

v1->v2:
- properly ifdef of_platform_bus_probe with CONFIG_OF
- handle of_platform_bus_probe errors and cleanup accordingly
- use of_property_read_u32 where applicable
- parse "duplex" and "speed" property in PHY-less configuration

Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
Documentation/devicetree/bindings/marvell.txt | 22 +++++-
drivers/net/ethernet/marvell/mv643xx_eth.c | 108 ++++++++++++++++++++++++-
include/linux/mv643xx_eth.h | 3 +
3 files changed, 128 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt
index f7a0da6..73ea12f 100644
--- a/Documentation/devicetree/bindings/marvell.txt
+++ b/Documentation/devicetree/bindings/marvell.txt
@@ -112,11 +112,13 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
Required properties:
- #address-cells : <1>
- #size-cells : <0>
- - compatible : "marvell,mv64360-eth-block"
+ - compatible : "marvell,mv64360-eth-block", "marvell,mv643xx-eth-block"
- reg : Offset and length of the register set for this block

Optional properties:
- clocks : Phandle to the clock control device and gate bit
+ - tx-csum-limit : Hardware limit above which transmit checksumming
+ is disabled.

Example Discovery Ethernet block node:
ethernet-***@2000 {
@@ -133,7 +135,7 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.

Required properties:
- device_type : Should be "network".
- - compatible : Should be "marvell,mv64360-eth".
+ - compatible : Should be "marvell,mv64360-eth", "marvell,mv643xx-eth"
- reg : Should be <0>, <1>, or <2>, according to which registers
within the silicon block the device uses.
- interrupts : <a> where a is the interrupt number for the port.
@@ -143,6 +145,22 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
controller.
- local-mac-address : 6 bytes, MAC address

+ Optional properties:
+ - clocks : Phandle to the clock control device and gate bit
+ - clock-names : String describing the clock gate bit
+ - speed : Speed to force the link (10, 100, 1000), used when no
+ phy property is defined
+ - duplex : Duplex to force the link (0: half, 1: full), used when no
+ phy property is defined
+ - rx-queue-count : number of RX queues to use
+ - tx-queue-count : number of TX queues to use
+ - rx-queue-size : size of the RX queue (in bytes)
+ - tx-queue-size : size of the TX queue (in bytes)
+ - rx-sram-addr : address of the SRAM for RX path (non 0 means used)
+ - rx-sram-size : size of the SRAM for RX path (non 0 means used)
+ - tx-sram-addr : address of the SRAM for TX path (non 0 means used)
+ - tx-sram-size : size of the SRAM for TX path (non 0 means used)
+
Example Discovery Ethernet port node:
***@0 {
device_type = "network";
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index d0afeea..efa5a2f 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -60,6 +60,11 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/stringify.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_mdio.h>
+#include <linux/of_net.h>

static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4";
@@ -2450,13 +2455,22 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
}
}

+static const struct of_device_id mv643xx_eth_match[] = {
+ { .compatible = "marvell,mv64360-eth" },
+ { .compatible = "marvell,mv643xx-eth" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_match);
+
static int mv643xx_eth_shared_probe(struct platform_device *pdev)
{
static int mv643xx_eth_version_printed;
+ struct device_node *np = pdev->dev.of_node;
struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
struct mv643xx_eth_shared_private *msp;
const struct mbus_dram_target_info *dram;
struct resource *res;
+ int tx_csum_limit = 0;

if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
@@ -2485,13 +2499,21 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);

- msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
- pd->tx_csum_limit : 9 * 1024;
+ if (np)
+ of_property_read_u32(np, "tx-csum-limit", &tx_csum_limit);
+ else
+ tx_csum_limit = pd->tx_csum_limit;
+
+ msp->tx_csum_limit = tx_csum_limit ? tx_csum_limit : 9 * 1024;
infer_hw_params(msp);

platform_set_drvdata(pdev, msp);

+#ifdef CONFIG_OF
+ return of_platform_bus_probe(np, mv643xx_eth_match, &pdev->dev);
+#else
return 0;
+#endif
}

static int mv643xx_eth_shared_remove(struct platform_device *pdev)
@@ -2505,12 +2527,20 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
return 0;
}

+static const struct of_device_id mv643xx_eth_shared_match[] = {
+ { .compatible = "marvell,mv64360-eth-block" },
+ { .compatible = "marvell,mv643xx-eth-block" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_match);
+
static struct platform_driver mv643xx_eth_shared_driver = {
.probe = mv643xx_eth_shared_probe,
.remove = mv643xx_eth_shared_remove,
.driver = {
.name = MV643XX_ETH_SHARED_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_shared_match),
},
};

@@ -2669,6 +2699,68 @@ static const struct net_device_ops mv643xx_eth_netdev_ops = {
#endif
};

+#ifdef CONFIG_OF
+static int mv643xx_eth_of_probe(struct platform_device *pdev)
+{
+ struct mv643xx_eth_platform_data *pd;
+ struct device_node *np = pdev->dev.of_node;
+ struct device_node *shared = of_get_parent(np);
+ const int *prop;
+ const char *mac_addr;
+
+ if (pdev->dev.platform_data || !pdev->dev.of_node)
+ return 0;
+
+ pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return -ENOMEM;
+
+ pdev->dev.platform_data = pd;
+
+ pd->shared = of_find_device_by_node(shared);
+ if (!pd->shared)
+ return -ENODEV;
+
+ if (of_property_read_u32(np, "reg", &pd->port_number))
+ return -EINVAL;
+
+ pd->phy_node = of_parse_phandle(np, "phy", 0);
+ if (!pd->phy_node) {
+ pd->phy_addr = MV643XX_ETH_PHY_NONE;
+
+ of_property_read_u32(np, "speed", &pd->speed);
+ of_property_read_u32(np, "duplex", &pd->duplex);
+ }
+
+ mac_addr = of_get_mac_address(np);
+ if (mac_addr)
+ memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
+
+#define rx_tx_queue_sram_property(_name) \
+ do { \
+ prop = of_get_property(np, __stringify(_name), NULL); \
+ if (prop) \
+ pd->_name = be32_to_cpup(prop); \
+ } while (0)
+
+ rx_tx_queue_sram_property(rx_queue_count);
+ rx_tx_queue_sram_property(tx_queue_count);
+ rx_tx_queue_sram_property(rx_queue_size);
+ rx_tx_queue_sram_property(tx_queue_size);
+ rx_tx_queue_sram_property(rx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+ rx_tx_queue_sram_property(tx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+
+ return 0;
+}
+#else
+static inline int mv643xx_eth_of_probe(struct platform_device *dev)
+{
+ return 0;
+}
+#endif
+
static int mv643xx_eth_probe(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *pd;
@@ -2677,6 +2769,10 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
struct resource *res;
int err;

+ err = mv643xx_eth_of_probe(pdev);
+ if (err)
+ return err;
+
pd = pdev->dev.platform_data;
if (pd == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
@@ -2717,7 +2813,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
netif_set_real_num_rx_queues(dev, mp->rxq_count);

if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
- mp->phy = phy_scan(mp, pd->phy_addr);
+ if (pd->phy_node)
+ mp->phy = of_phy_connect(mp->dev, pd->phy_node,
+ mv643xx_eth_adjust_link, 0,
+ PHY_INTERFACE_MODE_GMII);
+ else
+ mp->phy = phy_scan(mp, pd->phy_addr);

if (IS_ERR(mp->phy)) {
err = PTR_ERR(mp->phy);
@@ -2837,6 +2938,7 @@ static struct platform_driver mv643xx_eth_driver = {
.driver = {
.name = MV643XX_ETH_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_match),
},
};

diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index 141d395..c006d3d 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -30,6 +30,8 @@ struct mv643xx_eth_shared_platform_data {
#define MV643XX_ETH_PHY_ADDR(x) (0x80 | (x))
#define MV643XX_ETH_PHY_NONE 0xff

+struct device_node;
+
struct mv643xx_eth_platform_data {
/*
* Pointer back to our parent instance, and our port number.
@@ -41,6 +43,7 @@ struct mv643xx_eth_platform_data {
* Whether a PHY is present, and if yes, at which address.
*/
int phy_addr;
+ struct device_node *phy_node;

/*
* Use this MAC address if it is valid, overriding the
--
1.7.2.5
Simon Baatz
2013-05-20 21:19:31 UTC
Permalink
Hi Sebastian,
Post by Florian Fainelli
This patch adds Device Tree bindings following the already defined
bindings at Documentation/devicetree/bindings/marvell.txt. The binding
documentation is also enhanced with new optionnal properties required
for supporting certain devices (RX/TX queue and SRAM). Since we now have
proper support for the orion MDIO bus driver, there is no need to fiddle
around with device tree phandles. PHY-less (MAC connected to switch)
configurations are supported by not specifying any phy phandle for an
ethernet node.
---
- rebase on top of mv643xx_eth clean-ups
- do not reparse existing platform_data
- use managed devm_kzalloc for parsed platform_data
- use of_property_read_u32 where applicable
- add phy_node to platform_data
- use of_connect_phy if DT phy node was found
- properly ifdef of_platform_bus_probe with CONFIG_OF
- handle of_platform_bus_probe errors and cleanup accordingly
- use of_property_read_u32 where applicable
- parse "duplex" and "speed" property in PHY-less configuration
---
Documentation/devicetree/bindings/marvell.txt | 22 +++++-
drivers/net/ethernet/marvell/mv643xx_eth.c | 108 ++++++++++++++++++++++++-
include/linux/mv643xx_eth.h | 3 +
3 files changed, 128 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt
index f7a0da6..73ea12f 100644
--- a/Documentation/devicetree/bindings/marvell.txt
+++ b/Documentation/devicetree/bindings/marvell.txt
@@ -112,11 +112,13 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
- #address-cells : <1>
- #size-cells : <0>
- - compatible : "marvell,mv64360-eth-block"
+ - compatible : "marvell,mv64360-eth-block", "marvell,mv643xx-eth-block"
- reg : Offset and length of the register set for this block
- clocks : Phandle to the clock control device and gate bit
+ - tx-csum-limit : Hardware limit above which transmit checksumming
+ is disabled.
@@ -133,7 +135,7 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
- device_type : Should be "network".
- - compatible : Should be "marvell,mv64360-eth".
+ - compatible : Should be "marvell,mv64360-eth", "marvell,mv643xx-eth"
- reg : Should be <0>, <1>, or <2>, according to which registers
within the silicon block the device uses.
- interrupts : <a> where a is the interrupt number for the port.
@@ -143,6 +145,22 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
controller.
- local-mac-address : 6 bytes, MAC address
+ - clocks : Phandle to the clock control device and gate bit
+ - clock-names : String describing the clock gate bit
+ - speed : Speed to force the link (10, 100, 1000), used when no
+ phy property is defined
+ - duplex : Duplex to force the link (0: half, 1: full), used when no
+ phy property is defined
+ - rx-queue-count : number of RX queues to use
+ - tx-queue-count : number of TX queues to use
+ - rx-queue-size : size of the RX queue (in bytes)
+ - tx-queue-size : size of the TX queue (in bytes)
+ - rx-sram-addr : address of the SRAM for RX path (non 0 means used)
+ - rx-sram-size : size of the SRAM for RX path (non 0 means used)
+ - tx-sram-addr : address of the SRAM for TX path (non 0 means used)
+ - tx-sram-size : size of the SRAM for TX path (non 0 means used)
+
device_type = "network";
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index d0afeea..efa5a2f 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -60,6 +60,11 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/stringify.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_mdio.h>
+#include <linux/of_net.h>
static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4";
@@ -2450,13 +2455,22 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
}
}
+static const struct of_device_id mv643xx_eth_match[] = {
+ { .compatible = "marvell,mv64360-eth" },
+ { .compatible = "marvell,mv643xx-eth" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_match);
+
static int mv643xx_eth_shared_probe(struct platform_device *pdev)
{
static int mv643xx_eth_version_printed;
+ struct device_node *np = pdev->dev.of_node;
struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
struct mv643xx_eth_shared_private *msp;
const struct mbus_dram_target_info *dram;
struct resource *res;
+ int tx_csum_limit = 0;
if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
@@ -2485,13 +2499,21 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);
- msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
- pd->tx_csum_limit : 9 * 1024;
+ if (np)
+ of_property_read_u32(np, "tx-csum-limit", &tx_csum_limit);
+ else
+ tx_csum_limit = pd->tx_csum_limit;
+
+ msp->tx_csum_limit = tx_csum_limit ? tx_csum_limit : 9 * 1024;
infer_hw_params(msp);
platform_set_drvdata(pdev, msp);
+#ifdef CONFIG_OF
+ return of_platform_bus_probe(np, mv643xx_eth_match, &pdev->dev);
I have tested this on Kirkwood (Sheevaplug eSATA). When using
mv643xx_eth as a module with a built-in mvmdio the GbE port works.
However, when unloading the mv643xx_eth module and loading it again,
the second call to of_platform_bus_probe() results in a warning:

[ 190.542992] WARNING: at fs/sysfs/dir.c:530 sysfs_add_one+0x7c/0xa4()
[ 190.549372] sysfs: cannot create duplicate filename '/devices/ocp.0/f1072000.
ethernet-controller/0.ethernet-port'

(Looks more like a problem of of_platform_bus_probe() than a problem
in the driver?)
Post by Florian Fainelli
+#else
return 0;
+#endif
}
static int mv643xx_eth_shared_remove(struct platform_device *pdev)
@@ -2505,12 +2527,20 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
return 0;
}
+static const struct of_device_id mv643xx_eth_shared_match[] = {
+ { .compatible = "marvell,mv64360-eth-block" },
+ { .compatible = "marvell,mv643xx-eth-block" },
+ { },
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_match);
+
static struct platform_driver mv643xx_eth_shared_driver = {
.probe = mv643xx_eth_shared_probe,
.remove = mv643xx_eth_shared_remove,
.driver = {
.name = MV643XX_ETH_SHARED_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_shared_match),
},
};
@@ -2669,6 +2699,68 @@ static const struct net_device_ops mv643xx_eth_netdev_ops = {
#endif
};
+#ifdef CONFIG_OF
+static int mv643xx_eth_of_probe(struct platform_device *pdev)
+{
+ struct mv643xx_eth_platform_data *pd;
+ struct device_node *np = pdev->dev.of_node;
+ struct device_node *shared = of_get_parent(np);
+ const int *prop;
+ const char *mac_addr;
+
+ if (pdev->dev.platform_data || !pdev->dev.of_node)
+ return 0;
+
+ pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return -ENOMEM;
+
+ pdev->dev.platform_data = pd;
+
+ pd->shared = of_find_device_by_node(shared);
+ if (!pd->shared)
+ return -ENODEV;
+
+ if (of_property_read_u32(np, "reg", &pd->port_number))
+ return -EINVAL;
+
+ pd->phy_node = of_parse_phandle(np, "phy", 0);
+ if (!pd->phy_node) {
+ pd->phy_addr = MV643XX_ETH_PHY_NONE;
+
+ of_property_read_u32(np, "speed", &pd->speed);
+ of_property_read_u32(np, "duplex", &pd->duplex);
+ }
+
+ mac_addr = of_get_mac_address(np);
+ if (mac_addr)
+ memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
+
+#define rx_tx_queue_sram_property(_name) \
+ do { \
+ prop = of_get_property(np, __stringify(_name), NULL); \
+ if (prop) \
+ pd->_name = be32_to_cpup(prop); \
+ } while (0)
+
+ rx_tx_queue_sram_property(rx_queue_count);
+ rx_tx_queue_sram_property(tx_queue_count);
+ rx_tx_queue_sram_property(rx_queue_size);
+ rx_tx_queue_sram_property(tx_queue_size);
+ rx_tx_queue_sram_property(rx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+ rx_tx_queue_sram_property(tx_sram_addr);
+ rx_tx_queue_sram_property(rx_sram_size);
+
+ return 0;
+}
+#else
+static inline int mv643xx_eth_of_probe(struct platform_device *dev)
+{
+ return 0;
+}
+#endif
+
static int mv643xx_eth_probe(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *pd;
@@ -2677,6 +2769,10 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
struct resource *res;
int err;
+ err = mv643xx_eth_of_probe(pdev);
+ if (err)
+ return err;
+
pd = pdev->dev.platform_data;
if (pd == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
If the clock isn't already enabled (mvmdio and mv643xx_eth both built
as modules), a delay seems to be necessary in mv643xx_eth_probe()
after enabling the clock on my hardware. Otherwise the device hangs.
Andrew found the same in the past (see [1]). udelay(50) seems to be
sufficient in my case.
Post by Florian Fainelli
@@ -2717,7 +2813,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
netif_set_real_num_rx_queues(dev, mp->rxq_count);
if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
- mp->phy = phy_scan(mp, pd->phy_addr);
+ if (pd->phy_node)
+ mp->phy = of_phy_connect(mp->dev, pd->phy_node,
+ mv643xx_eth_adjust_link, 0,
+ PHY_INTERFACE_MODE_GMII);
of_phy_connect() returns NULL in case of an error and no ERR_PTR.

- Simon

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2012-June/103521.html
Sebastian Hesselbarth
2013-05-20 21:34:40 UTC
Permalink
...
Post by Simon Baatz
Post by Sebastian Hesselbarth
@@ -2485,13 +2499,21 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);
- msp->tx_csum_limit = (pd != NULL&& pd->tx_csum_limit) ?
- pd->tx_csum_limit : 9 * 1024;
+ if (np)
+ of_property_read_u32(np, "tx-csum-limit",&tx_csum_limit);
+ else
+ tx_csum_limit = pd->tx_csum_limit;
+
+ msp->tx_csum_limit = tx_csum_limit ? tx_csum_limit : 9 * 1024;
infer_hw_params(msp);
platform_set_drvdata(pdev, msp);
+#ifdef CONFIG_OF
+ return of_platform_bus_probe(np, mv643xx_eth_match,&pdev->dev);
I have tested this on Kirkwood (Sheevaplug eSATA). When using
mv643xx_eth as a module with a built-in mvmdio the GbE port works.
However, when unloading the mv643xx_eth module and loading it again,
[ 190.542992] WARNING: at fs/sysfs/dir.c:530 sysfs_add_one+0x7c/0xa4()
[ 190.549372] sysfs: cannot create duplicate filename '/devices/ocp.0/f1072000.
ethernet-controller/0.ethernet-port'
(Looks more like a problem of of_platform_bus_probe() than a problem
in the driver?)
Hi Simon,

thanks for the review. I am right now working on a v4 of the DT support
patches for mv643xx_eth and the above will not be there anymore. I will
test v4 for rmmod/modprobe issues before posting.
Post by Simon Baatz
Post by Sebastian Hesselbarth
@@ -2677,6 +2769,10 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
struct resource *res;
int err;
+ err = mv643xx_eth_of_probe(pdev);
+ if (err)
+ return err;
+
pd = pdev->dev.platform_data;
if (pd == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
If the clock isn't already enabled (mvmdio and mv643xx_eth both built
as modules), a delay seems to be necessary in mv643xx_eth_probe()
after enabling the clock on my hardware. Otherwise the device hangs.
Andrew found the same in the past (see [1]). udelay(50) seems to be
sufficient in my case.
Hmm, I am wondering if that delay shouldn't be in the clock provider
then. I test it on Dove also and look for a way to insert the delay
if neccessary. Maybe Andrew can also comment on this.
Post by Simon Baatz
Post by Sebastian Hesselbarth
@@ -2717,7 +2813,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
netif_set_real_num_rx_queues(dev, mp->rxq_count);
if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
- mp->phy = phy_scan(mp, pd->phy_addr);
+ if (pd->phy_node)
+ mp->phy = of_phy_connect(mp->dev, pd->phy_node,
+ mv643xx_eth_adjust_link, 0,
+ PHY_INTERFACE_MODE_GMII);
of_phy_connect() returns NULL in case of an error and no ERR_PTR.
True, will take care of that.

Sebastian
Sebastian Hesselbarth
2013-05-06 15:33:35 UTC
Permalink
From: Florian Fainelli <florian-***@public.gmane.org>

This patch updates the Device Tree bindings documentation for the
Marvell MV643xx ethernet controller node and makes the
"local-mac-address" and "phy" properties optional instead of required.
The absence of a "phy" node is legal and describes a MAC to switch
configuration, while not specifying the "local-mac-address" allows for
reuse of the MAC address already programmed into the Ethernet
controller.

Signed-off-by: Florian Fainelli <florian-***@public.gmane.org>
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
Documentation/devicetree/bindings/marvell.txt | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt
index 73ea12f..ed4058c 100644
--- a/Documentation/devicetree/bindings/marvell.txt
+++ b/Documentation/devicetree/bindings/marvell.txt
@@ -141,11 +141,11 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
- interrupts : <a> where a is the interrupt number for the port.
- interrupt-parent : the phandle for the interrupt controller
that services interrupts for this device.
+
+ Optional properties:
- phy : the phandle for the PHY connected to this ethernet
controller.
- local-mac-address : 6 bytes, MAC address
-
- Optional properties:
- clocks : Phandle to the clock control device and gate bit
- clock-names : String describing the clock gate bit
- speed : Speed to force the link (10, 100, 1000), used when no
--
1.7.2.5
Sebastian Hesselbarth
2013-05-06 15:33:36 UTC
Permalink
With DT support for mv643xx_eth we do not need legacy platform_data
based setup for DT enabled boards.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-***@public.gmane.org>
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
arch/arm/mach-dove/board-dt.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-dove/board-dt.c b/arch/arm/mach-dove/board-dt.c
index fbde1dd..3c0963d 100644
--- a/arch/arm/mach-dove/board-dt.c
+++ b/arch/arm/mach-dove/board-dt.c
@@ -34,10 +34,6 @@ static void __init dove_legacy_clk_init(void)
clkspec.np = np;
clkspec.args_count = 1;

- clkspec.args[0] = CLOCK_GATING_BIT_GBE;
- orion_clkdev_add(NULL, "mv643xx_eth_port.0",
- of_clk_get_from_provider(&clkspec));
-
clkspec.args[0] = CLOCK_GATING_BIT_PCIE0;
orion_clkdev_add("0", "pcie",
of_clk_get_from_provider(&clkspec));
@@ -70,7 +66,6 @@ static void __init dove_dt_init(void)
dove_of_clk_init();

/* Internal devices not ported to DT yet */
- dove_ge00_init(&dove_dt_ge00_data);
dove_pcie_init(1, 1);

of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
--
1.7.2.5
Sebastian Hesselbarth
2013-05-06 15:33:37 UTC
Permalink
This patch adds mv643xx_eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to overwrite its reg property on a
per-board basis.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-***@public.gmane.org>
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
arch/arm/boot/dts/dove-cubox.dts | 8 ++++++++
arch/arm/boot/dts/dove.dtsi | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/dove-cubox.dts b/arch/arm/boot/dts/dove-cubox.dts
index 7e3065a..a52f016 100644
--- a/arch/arm/boot/dts/dove-cubox.dts
+++ b/arch/arm/boot/dts/dove-cubox.dts
@@ -49,6 +49,14 @@
&uart0 { status = "okay"; };
&sata0 { status = "okay"; };
&i2c0 { status = "okay"; };
+&mdio { status = "okay"; };
+&eth { status = "okay"; };
+&eth0 { status = "okay"; };
+
+&ethphy {
+ compatible = "marvell,88e1310";
+ reg = <1>;
+};

&sdio0 {
status = "okay";
diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index 6cab468..8bb46c4 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -258,5 +258,40 @@
dmacap,xor;
};
};
+
+ mdio: mdio-***@72004 {
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
+ interrupts = <30>;
+ clocks = <&gate_clk 2>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+
+ ethphy: ethernet-phy {
+ device_type = "ethernet-phy";
+ /* overwrite reg property in board file */
+ };
+ };
+
+ eth: ethernet-***@72000 {
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x72000 0x4000>;
+ clocks = <&gate_clk 2>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ tx-csum-limit = <1600>;
+ status = "disabled";
+
+ eth0: ethernet-***@0 {
+ compatible = "marvell,mv643xx-eth";
+ device_type = "network";
+ reg = <0>;
+ interrupts = <29>;
+ clocks = <&gate_clk 2>;
+ phy = <&ethphy>;
+ status = "disabled";
+ };
+ };
};
};
--
1.7.2.5
Sebastian Hesselbarth
2013-05-06 15:33:38 UTC
Permalink
With DT support for mv643xx_eth we do not need legacy platform_data
based setup for DT enabled boards. This patch removes eth setup
for all kirkwood DT board files.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-***@public.gmane.org>
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
arch/arm/mach-kirkwood/board-dnskw.c | 7 -------
arch/arm/mach-kirkwood/board-dockstar.c | 9 ---------
arch/arm/mach-kirkwood/board-dreamplug.c | 14 --------------
arch/arm/mach-kirkwood/board-goflexnet.c | 9 ---------
arch/arm/mach-kirkwood/board-guruplug.c | 14 --------------
arch/arm/mach-kirkwood/board-ib62x0.c | 9 ---------
arch/arm/mach-kirkwood/board-iconnect.c | 6 ------
arch/arm/mach-kirkwood/board-iomega_ix2_200.c | 16 ----------------
arch/arm/mach-kirkwood/board-km_kirkwood.c | 7 -------
arch/arm/mach-kirkwood/board-lsxl.c | 12 ------------
arch/arm/mach-kirkwood/board-mplcec4.c | 11 -----------
arch/arm/mach-kirkwood/board-ns2.c | 13 -------------
arch/arm/mach-kirkwood/board-openblocks_a6.c | 9 ---------
arch/arm/mach-kirkwood/board-readynas.c | 6 ------
arch/arm/mach-kirkwood/board-ts219.c | 13 -------------
arch/arm/mach-kirkwood/board-usi_topkick.c | 9 ---------
16 files changed, 0 insertions(+), 164 deletions(-)

diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index a1aa87f..2af7a95 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -14,14 +14,9 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <linux/gpio.h>
#include "common.h"

-static struct mv643xx_eth_platform_data dnskw_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
/* Register any GPIO for output and set the value */
static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
{
@@ -36,8 +31,6 @@ static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)

void __init dnskw_init(void)
{
- kirkwood_ge00_init(&dnskw_ge00_data);
-
/* Set NAS to turn back on after a power failure */
dnskw_gpio_register(37, "dnskw:power:recover", 1);
}
diff --git a/arch/arm/mach-kirkwood/board-dockstar.c b/arch/arm/mach-kirkwood/board-dockstar.c
index d7196db..b78032e 100644
--- a/arch/arm/mach-kirkwood/board-dockstar.c
+++ b/arch/arm/mach-kirkwood/board-dockstar.c
@@ -16,17 +16,8 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data dockstar_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init dockstar_dt_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&dockstar_ge00_data);
}
diff --git a/arch/arm/mach-kirkwood/board-dreamplug.c b/arch/arm/mach-kirkwood/board-dreamplug.c
index 0903242..cb7823d 100644
--- a/arch/arm/mach-kirkwood/board-dreamplug.c
+++ b/arch/arm/mach-kirkwood/board-dreamplug.c
@@ -13,23 +13,9 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include <linux/gpio.h>
#include "common.h"

-static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data dreamplug_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(1),
-};
-
void __init dreamplug_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&dreamplug_ge00_data);
- kirkwood_ge01_init(&dreamplug_ge01_data);
}
diff --git a/arch/arm/mach-kirkwood/board-goflexnet.c b/arch/arm/mach-kirkwood/board-goflexnet.c
index 9db979a..4213e20 100644
--- a/arch/arm/mach-kirkwood/board-goflexnet.c
+++ b/arch/arm/mach-kirkwood/board-goflexnet.c
@@ -18,17 +18,8 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data goflexnet_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init goflexnet_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&goflexnet_ge00_data);
}
diff --git a/arch/arm/mach-kirkwood/board-guruplug.c b/arch/arm/mach-kirkwood/board-guruplug.c
index a857163..d515f64 100644
--- a/arch/arm/mach-kirkwood/board-guruplug.c
+++ b/arch/arm/mach-kirkwood/board-guruplug.c
@@ -11,23 +11,9 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include <linux/gpio.h>
#include "common.h"

-static struct mv643xx_eth_platform_data guruplug_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data guruplug_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(1),
-};
-
void __init guruplug_dt_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&guruplug_ge00_data);
- kirkwood_ge01_init(&guruplug_ge01_data);
}
diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c
index 9a857ae..6082373 100644
--- a/arch/arm/mach-kirkwood/board-ib62x0.c
+++ b/arch/arm/mach-kirkwood/board-ib62x0.c
@@ -13,17 +13,8 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
void __init ib62x0_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&ib62x0_ge00_data);
}
diff --git a/arch/arm/mach-kirkwood/board-iconnect.c b/arch/arm/mach-kirkwood/board-iconnect.c
index c8ebde4..045668c 100644
--- a/arch/arm/mach-kirkwood/board-iconnect.c
+++ b/arch/arm/mach-kirkwood/board-iconnect.c
@@ -11,16 +11,10 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/of.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data iconnect_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(11),
-};
-
void __init iconnect_init(void)
{
- kirkwood_ge00_init(&iconnect_ge00_data);
}

static int __init iconnect_pci_init(void)
diff --git a/arch/arm/mach-kirkwood/board-iomega_ix2_200.c b/arch/arm/mach-kirkwood/board-iomega_ix2_200.c
index e5f7041..dc86cf7 100644
--- a/arch/arm/mach-kirkwood/board-iomega_ix2_200.c
+++ b/arch/arm/mach-kirkwood/board-iomega_ix2_200.c
@@ -10,25 +10,9 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include <linux/ethtool.h>
#include "common.h"

-static struct mv643xx_eth_platform_data iomega_ix2_200_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_NONE,
- .speed = SPEED_1000,
- .duplex = DUPLEX_FULL,
-};
-
-static struct mv643xx_eth_platform_data iomega_ix2_200_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(11),
-};
-
void __init iomega_ix2_200_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&iomega_ix2_200_ge00_data);
- kirkwood_ge01_init(&iomega_ix2_200_ge01_data);
}
diff --git a/arch/arm/mach-kirkwood/board-km_kirkwood.c b/arch/arm/mach-kirkwood/board-km_kirkwood.c
index 44e4605..6b8464b 100644
--- a/arch/arm/mach-kirkwood/board-km_kirkwood.c
+++ b/arch/arm/mach-kirkwood/board-km_kirkwood.c
@@ -14,15 +14,10 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include <linux/clk.h>
#include <linux/clk-private.h>
#include "common.h"

-static struct mv643xx_eth_platform_data km_kirkwood_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init km_kirkwood_init(void)
{
struct clk *sata_clk;
@@ -39,6 +34,4 @@ void __init km_kirkwood_init(void)
sata_clk = clk_get_sys("sata_mv.0", "1");
if (!IS_ERR(sata_clk))
sata_clk->flags |= CLK_IGNORE_UNUSED;
-
- kirkwood_ge00_init(&km_kirkwood_ge00_data);
}
diff --git a/arch/arm/mach-kirkwood/board-lsxl.c b/arch/arm/mach-kirkwood/board-lsxl.c
index 4ec8b7a..1cbcd56 100644
--- a/arch/arm/mach-kirkwood/board-lsxl.c
+++ b/arch/arm/mach-kirkwood/board-lsxl.c
@@ -14,17 +14,8 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data lsxl_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data lsxl_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
/*
* On the LS-XHL/LS-CHLv2, the shutdown process is following:
* - Userland monitors key events until the power switch goes to off position
@@ -44,9 +35,6 @@ void __init lsxl_init(void)
* Basic setup. Needs to be called early.
*/

- kirkwood_ge00_init(&lsxl_ge00_data);
- kirkwood_ge01_init(&lsxl_ge01_data);
-
/* register power-off method */
pm_power_off = lsxl_power_off;
}
diff --git a/arch/arm/mach-kirkwood/board-mplcec4.c b/arch/arm/mach-kirkwood/board-mplcec4.c
index 7d6dc66..a337ef5 100644
--- a/arch/arm/mach-kirkwood/board-mplcec4.c
+++ b/arch/arm/mach-kirkwood/board-mplcec4.c
@@ -11,24 +11,13 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data mplcec4_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(1),
-};
-
-static struct mv643xx_eth_platform_data mplcec4_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(2),
-};
-
void __init mplcec4_init(void)
{
/*
* Basic setup. Needs to be called early.
*/
- kirkwood_ge00_init(&mplcec4_ge00_data);
- kirkwood_ge01_init(&mplcec4_ge01_data);
kirkwood_pcie_init(KW_PCIE0);
}

diff --git a/arch/arm/mach-kirkwood/board-ns2.c b/arch/arm/mach-kirkwood/board-ns2.c
index f8f6605..ba3abd6 100644
--- a/arch/arm/mach-kirkwood/board-ns2.c
+++ b/arch/arm/mach-kirkwood/board-ns2.c
@@ -14,22 +14,9 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <linux/of.h>
#include "common.h"

-static struct mv643xx_eth_platform_data ns2_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
void __init ns2_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- if (of_machine_is_compatible("lacie,cloudbox") ||
- of_machine_is_compatible("lacie,netspace_lite_v2") ||
- of_machine_is_compatible("lacie,netspace_mini_v2"))
- ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
- kirkwood_ge00_init(&ns2_ge00_data);
}
diff --git a/arch/arm/mach-kirkwood/board-openblocks_a6.c b/arch/arm/mach-kirkwood/board-openblocks_a6.c
index b11d8fd..120dccf 100644
--- a/arch/arm/mach-kirkwood/board-openblocks_a6.c
+++ b/arch/arm/mach-kirkwood/board-openblocks_a6.c
@@ -10,17 +10,8 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data openblocks_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init openblocks_a6_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&openblocks_ge00_data);
}
diff --git a/arch/arm/mach-kirkwood/board-readynas.c b/arch/arm/mach-kirkwood/board-readynas.c
index fb42c20..3ab3e0e 100644
--- a/arch/arm/mach-kirkwood/board-readynas.c
+++ b/arch/arm/mach-kirkwood/board-readynas.c
@@ -13,16 +13,10 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <mach/kirkwood.h>
#include "common.h"

-static struct mv643xx_eth_platform_data netgear_readynas_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init netgear_readynas_init(void)
{
- kirkwood_ge00_init(&netgear_readynas_ge00_data);
kirkwood_pcie_init(KW_PCIE0);
}
diff --git a/arch/arm/mach-kirkwood/board-ts219.c b/arch/arm/mach-kirkwood/board-ts219.c
index acb0187..854d448 100644
--- a/arch/arm/mach-kirkwood/board-ts219.c
+++ b/arch/arm/mach-kirkwood/board-ts219.c
@@ -18,27 +18,14 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <mach/kirkwood.h>
#include "common.h"
#include "tsx1x-common.h"

-static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
void __init qnap_dt_ts219_init(void)
{
- u32 dev, rev;
-
- kirkwood_pcie_id(&dev, &rev);
- if (dev == MV88F6282_DEV_ID)
- qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
-
- kirkwood_ge00_init(&qnap_ts219_ge00_data);
-
pm_power_off = qnap_tsx1x_power_off;
}

diff --git a/arch/arm/mach-kirkwood/board-usi_topkick.c b/arch/arm/mach-kirkwood/board-usi_topkick.c
index 1cc04ec..44a8a6b 100644
--- a/arch/arm/mach-kirkwood/board-usi_topkick.c
+++ b/arch/arm/mach-kirkwood/board-usi_topkick.c
@@ -12,18 +12,9 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include <linux/gpio.h>
#include "common.h"

-static struct mv643xx_eth_platform_data topkick_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init usi_topkick_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&topkick_ge00_data);
}
--
1.7.2.5
Thomas Petazzoni
2013-05-06 15:39:09 UTC
Permalink
Dear Sebastian Hesselbarth,
Post by Sebastian Hesselbarth
With DT support for mv643xx_eth we do not need legacy platform_data
based setup for DT enabled boards. This patch removes eth setup
for all kirkwood DT board files.
arch/arm/mach-kirkwood/board-dnskw.c | 7 -------
arch/arm/mach-kirkwood/board-dockstar.c | 9 ---------
arch/arm/mach-kirkwood/board-dreamplug.c | 14 --------------
arch/arm/mach-kirkwood/board-goflexnet.c | 9 ---------
arch/arm/mach-kirkwood/board-guruplug.c | 14 --------------
arch/arm/mach-kirkwood/board-ib62x0.c | 9 ---------
arch/arm/mach-kirkwood/board-iconnect.c | 6 ------
arch/arm/mach-kirkwood/board-iomega_ix2_200.c | 16 ----------------
arch/arm/mach-kirkwood/board-km_kirkwood.c | 7 -------
arch/arm/mach-kirkwood/board-lsxl.c | 12 ------------
arch/arm/mach-kirkwood/board-mplcec4.c | 11 -----------
arch/arm/mach-kirkwood/board-ns2.c | 13 -------------
arch/arm/mach-kirkwood/board-openblocks_a6.c | 9 ---------
arch/arm/mach-kirkwood/board-readynas.c | 6 ------
arch/arm/mach-kirkwood/board-ts219.c | 13 -------------
arch/arm/mach-kirkwood/board-usi_topkick.c | 9 ---------
I believe a good number of those files become empty once you've removed
the registration of the Ethernet devices. Shouldn't such files be
removed in this patch?

Thanks!

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
Sebastian Hesselbarth
2013-05-06 15:33:39 UTC
Permalink
This patch adds mv643xx_eth and mvmdio device tree nodes for DT enabled
Kirkwood boards. Phy nodes are also added with reg property set on a
per-board basis.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-***@public.gmane.org>
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
arch/arm/boot/dts/kirkwood-cloudbox.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-dnskw.dtsi | 15 ++++++
arch/arm/boot/dts/kirkwood-dockstar.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-dreamplug.dts | 26 ++++++++++
arch/arm/boot/dts/kirkwood-goflexnet.dts | 15 ++++++
.../arm/boot/dts/kirkwood-guruplug-server-plus.dts | 26 ++++++++++
arch/arm/boot/dts/kirkwood-ib62x0.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-iconnect.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts | 22 ++++++++
arch/arm/boot/dts/kirkwood-is2.dts | 2 +
arch/arm/boot/dts/kirkwood-km_kirkwood.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-lsxl.dtsi | 26 ++++++++++
arch/arm/boot/dts/kirkwood-mplcec4.dts | 25 +++++++++
.../boot/dts/kirkwood-netgear_readynas_duo_v2.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-ns2-common.dtsi | 15 ++++++
arch/arm/boot/dts/kirkwood-ns2.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2lite.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2max.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2mini.dts | 2 +
arch/arm/boot/dts/kirkwood-openblocks_a6.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-topkick.dts | 15 ++++++
arch/arm/boot/dts/kirkwood-ts219-6281.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219-6282.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219.dtsi | 15 ++++++
arch/arm/boot/dts/kirkwood.dtsi | 52 ++++++++++++++++++++
25 files changed, 373 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-cloudbox.dts b/arch/arm/boot/dts/kirkwood-cloudbox.dts
index 5f21d4e..d4f1e89 100644
--- a/arch/arm/boot/dts/kirkwood-cloudbox.dts
+++ b/arch/arm/boot/dts/kirkwood-cloudbox.dts
@@ -87,3 +87,18 @@
gpios = <&gpio0 17 0>;
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
index 6875ac0..b203f07 100644
--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -217,3 +217,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ reg = <8>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dockstar.dts b/arch/arm/boot/dts/kirkwood-dockstar.dts
index 0196cf6..1b46882 100644
--- a/arch/arm/boot/dts/kirkwood-dockstar.dts
+++ b/arch/arm/boot/dts/kirkwood-dockstar.dts
@@ -91,3 +91,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
index 289e51d..3ce258b 100644
--- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -99,3 +99,29 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&eth1 { status = "okay"; };
+&egiga1 {
+ status = "okay";
+ phy = <&ethphy1>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+
+ ethphy1: ethernet-***@1 {
+ device_type = "ethernet-phy";
+ reg = <1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-goflexnet.dts b/arch/arm/boot/dts/kirkwood-goflexnet.dts
index c3573be..84fe313 100644
--- a/arch/arm/boot/dts/kirkwood-goflexnet.dts
+++ b/arch/arm/boot/dts/kirkwood-goflexnet.dts
@@ -170,3 +170,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts b/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts
index 44fd97d..894e658 100644
--- a/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts
+++ b/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts
@@ -96,3 +96,29 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&eth1 { status = "okay"; };
+&egiga1 {
+ status = "okay";
+ phy = <&ethphy1>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+
+ ethphy1: ethernet-***@1 {
+ device_type = "ethernet-phy";
+ reg = <1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index 5335b1a..7e7845d 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -119,3 +119,18 @@


};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ reg = <8>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-iconnect.dts b/arch/arm/boot/dts/kirkwood-iconnect.dts
index 12ccf74..7991168 100644
--- a/arch/arm/boot/dts/kirkwood-iconnect.dts
+++ b/arch/arm/boot/dts/kirkwood-iconnect.dts
@@ -168,3 +168,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@11 {
+ device_type = "ethernet-phy";
+ reg = <11>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts b/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts
index 3694e94..40e85aa 100644
--- a/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts
+++ b/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts
@@ -191,3 +191,25 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ speed = <1000>;
+ duplex = <1>;
+};
+
+&eth1 { status = "okay"; };
+&egiga1 {
+ status = "okay";
+ phy = <&ethphy1>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy1: ethernet-***@11 {
+ device_type = "ethernet-phy";
+ reg = <11>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-is2.dts b/arch/arm/boot/dts/kirkwood-is2.dts
index 0bdce0a..2e5fe72 100644
--- a/arch/arm/boot/dts/kirkwood-is2.dts
+++ b/arch/arm/boot/dts/kirkwood-is2.dts
@@ -28,3 +28,5 @@
};
};
};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-km_kirkwood.dts b/arch/arm/boot/dts/kirkwood-km_kirkwood.dts
index 5bbd054..fd97497 100644
--- a/arch/arm/boot/dts/kirkwood-km_kirkwood.dts
+++ b/arch/arm/boot/dts/kirkwood-km_kirkwood.dts
@@ -43,3 +43,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-lsxl.dtsi b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
index 37d45c4..e9d61db 100644
--- a/arch/arm/boot/dts/kirkwood-lsxl.dtsi
+++ b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
@@ -201,3 +201,29 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&eth1 { status = "okay"; };
+&egiga1 {
+ status = "okay";
+ phy = <&ethphy1>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+
+ ethphy1: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ reg = <8>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-mplcec4.dts b/arch/arm/boot/dts/kirkwood-mplcec4.dts
index 7588241..326cc48 100644
--- a/arch/arm/boot/dts/kirkwood-mplcec4.dts
+++ b/arch/arm/boot/dts/kirkwood-mplcec4.dts
@@ -182,3 +182,28 @@
};
};

+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&eth1 { status = "okay"; };
+&egiga1 {
+ status = "okay";
+ phy = <&ethphy1>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@1 {
+ device_type = "ethernet-phy";
+ reg = <1>;
+ };
+
+ ethphy1: ethernet-***@2 {
+ device_type = "ethernet-phy";
+ reg = <2>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts b/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts
index 1ca66ab..f3b39f7 100644
--- a/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts
+++ b/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts
@@ -178,3 +178,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ns2-common.dtsi b/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
index 6affd92..b205832 100644
--- a/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
@@ -82,3 +82,18 @@
};

};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-phy {
+ device_type = "ethernet-phy";
+ /* overwrite reg property in board file */
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ns2.dts b/arch/arm/boot/dts/kirkwood-ns2.dts
index f2d36ecf..8ffd552 100644
--- a/arch/arm/boot/dts/kirkwood-ns2.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2.dts
@@ -28,3 +28,5 @@
};
};
};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ns2lite.dts b/arch/arm/boot/dts/kirkwood-ns2lite.dts
index b02eb4e..16332f8 100644
--- a/arch/arm/boot/dts/kirkwood-ns2lite.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2lite.dts
@@ -28,3 +28,5 @@
};
};
};
+
+&ethphy0 { reg = <0>; };
diff --git a/arch/arm/boot/dts/kirkwood-ns2max.dts b/arch/arm/boot/dts/kirkwood-ns2max.dts
index bcec4d6..68d767d 100644
--- a/arch/arm/boot/dts/kirkwood-ns2max.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2max.dts
@@ -47,3 +47,5 @@
};
};
};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ns2mini.dts b/arch/arm/boot/dts/kirkwood-ns2mini.dts
index adab1ab..5b1b17b 100644
--- a/arch/arm/boot/dts/kirkwood-ns2mini.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2mini.dts
@@ -48,3 +48,5 @@
};
};
};
+
+&ethphy0 { reg = <0>; };
diff --git a/arch/arm/boot/dts/kirkwood-openblocks_a6.dts b/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
index d27f724..d8109f9 100644
--- a/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
+++ b/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
@@ -210,3 +210,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-topkick.dts b/arch/arm/boot/dts/kirkwood-topkick.dts
index 66eb45b..dc3bb78 100644
--- a/arch/arm/boot/dts/kirkwood-topkick.dts
+++ b/arch/arm/boot/dts/kirkwood-topkick.dts
@@ -201,3 +201,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6281.dts b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
index 8295c83..0bd67bf 100644
--- a/arch/arm/boot/dts/kirkwood-ts219-6281.dts
+++ b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
@@ -49,4 +49,6 @@
gpios = <&gpio0 16 1>;
};
};
-};
\ No newline at end of file
+};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6282.dts b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
index df3f95d..a1bdef6 100644
--- a/arch/arm/boot/dts/kirkwood-ts219-6282.dts
+++ b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
@@ -49,4 +49,6 @@
gpios = <&gpio1 5 1>;
};
};
-};
\ No newline at end of file
+};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ts219.dtsi b/arch/arm/boot/dts/kirkwood-ts219.dtsi
index 64ea27c..5865dc5 100644
--- a/arch/arm/boot/dts/kirkwood-ts219.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ts219.dtsi
@@ -76,3 +76,18 @@
};
};
};
+
+&eth0 { status = "okay"; };
+&egiga0 {
+ status = "okay";
+ phy = <&ethphy0>;
+};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-phy {
+ device_type = "ethernet-phy";
+ /* overwrite reg property in board file */
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index fada7e6..c01a273 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -202,5 +202,57 @@
clocks = <&gate_clk 4>;
status = "disabled";
};
+
+ mdio: mdio-***@72004 {
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
+ interrupts = <11>;
+ clocks = <&gate_clk 0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+
+ /* add phy nodes in board file */
+ };
+
+ eth0: ethernet-***@72000 {
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x72000 0x4000>;
+ clocks = <&gate_clk 0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ tx-csum-limit = <1600>;
+ status = "disabled";
+
+ egiga0: ethernet-***@0 {
+ compatible = "marvell,mv643xx-eth";
+ device_type = "network";
+ reg = <0>;
+ interrupts = <11>;
+ clocks = <&gate_clk 0>;
+ /* set phy property in board file */
+ status = "disabled";
+ };
+ };
+
+ eth1: ethernet-***@76000 {
+ compatible = "marvell,mv643xx-eth-block";
+ reg = <0x76000 0x4000>;
+ clocks = <&gate_clk 19>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ tx-csum-limit = <1600>;
+ status = "disabled";
+
+ egiga1: ethernet-***@1 {
+ compatible = "marvell,mv643xx-eth";
+ device_type = "network";
+ reg = <1>;
+ interrupts = <15>;
+ clocks = <&gate_clk 19>;
+ /* set phy property in board file */
+ status = "disabled";
+ };
+ };
};
};
--
1.7.2.5
Simon Baatz
2013-05-20 21:27:08 UTC
Permalink
Hi Sebastian,
Post by Sebastian Hesselbarth
This patch adds mv643xx_eth and mvmdio device tree nodes for DT enabled
Kirkwood boards. Phy nodes are also added with reg property set on a
per-board basis.
...
Post by Sebastian Hesselbarth
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index fada7e6..c01a273 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -202,5 +202,57 @@
clocks = <&gate_clk 4>;
status = "disabled";
};
+
+ compatible = "marvell,orion-mdio";
+ reg = <0x72004 0x84>;
+ interrupts = <11>;
Shouldn't this be 46?

- Simon

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Sebastian Hesselbarth
2013-05-20 21:38:00 UTC
Permalink
Post by Simon Baatz
Hi Sebastian,
Post by Sebastian Hesselbarth
This patch adds mv643xx_eth and mvmdio device tree nodes for DT enabled
Kirkwood boards. Phy nodes are also added with reg property set on a
per-board basis.
...
Post by Sebastian Hesselbarth
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index fada7e6..c01a273 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -202,5 +202,57 @@
clocks =<&gate_clk 4>;
status = "disabled";
};
+
+ compatible = "marvell,orion-mdio";
+ reg =<0x72004 0x84>;
+ interrupts =<11>;
Shouldn't this be 46?
Yes, mdio is using GbE0Err interrupt and that is 14 on IRQ HIGH CAUSE.
I was misled by 11 on IRQ LOW CAUSE.

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Sebastian Hesselbarth
2013-05-06 15:33:40 UTC
Permalink
With all boards converted to DT enabled mv643xx_eth we can now
remove the clock alias for gbe clocks.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-***@public.gmane.org>
---
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+***@public.gmane.org>
Cc: Rob Herring <rob.herring-bsGFqQB8/***@public.gmane.org>
Cc: Rob Landley <rob-VoJi6FS/***@public.gmane.org>
Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/***@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/***@public.gmane.org>
Cc: Florian Fainelli <florian-***@public.gmane.org>
Cc: Arnaud Patard <arnaud.patard-dQbF7i+***@public.gmane.org>
Cc: Russell King <linux-lFZ/***@public.gmane.org>
Cc: Jason Cooper <jason-***@public.gmane.org>
Cc: Andrew Lunn <andrew-***@public.gmane.org>
Cc: Jean-Francois Moine <moinejf-***@public.gmane.org>
Cc: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/***@public.gmane.org>
Cc: Simon Guinot <simon.guinot-***@public.gmane.org>
Cc: Jamie Lentin <jm-Pj/***@public.gmane.org>
Cc: Michael Walle <michael-***@public.gmane.org>
Cc: Eric Hutter <hutter.eric-***@public.gmane.org>
Cc: Joshua Coombs <josh.coombs-***@public.gmane.org>
Cc: Willy Tarreau <***@1wt.eu>
Cc: Simon Baatz <gmbnomis-***@public.gmane.org>
Cc: Alan M Butler <alanbutty12-***@public.gmane.org>
Cc: Nigel Roberts <nigel-BZPLJ9//***@public.gmane.org>
Cc: Valentin Longchamp <valentin.longchamp-SkAbAL50j+***@public.gmane.org>
Cc: Stefan Peter <s.peter-***@public.gmane.org>
Cc: Arnaud Ebalard <arno-***@public.gmane.org>
Cc: Nobuhiro Iwamatsu <iwamatsu-+***@public.gmane.org>
Cc: netdev-***@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/***@public.gmane.org
Cc: linux-doc-***@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+***@public.gmane.org
Cc: linux-kernel-***@public.gmane.org
---
arch/arm/mach-kirkwood/board-dt.c | 16 ----------------
1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 7904758..f474cb9 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -42,7 +42,6 @@ static void __init kirkwood_legacy_clk_init(void)
struct device_node *np = of_find_compatible_node(
NULL, NULL, "marvell,kirkwood-gating-clock");
struct of_phandle_args clkspec;
- struct clk *clk;

clkspec.np = np;
clkspec.args_count = 1;
@@ -58,21 +57,6 @@ static void __init kirkwood_legacy_clk_init(void)
clkspec.args[0] = CGC_BIT_SDIO;
orion_clkdev_add(NULL, "mvsdio",
of_clk_get_from_provider(&clkspec));
-
- /*
- * The ethernet interfaces forget the MAC address assigned by
- * u-boot if the clocks are turned off. Until proper DT support
- * is available we always enable them for now.
- */
- clkspec.args[0] = CGC_BIT_GE0;
- clk = of_clk_get_from_provider(&clkspec);
- orion_clkdev_add(NULL, "mv643xx_eth_port.0", clk);
- clk_prepare_enable(clk);
-
- clkspec.args[0] = CGC_BIT_GE1;
- clk = of_clk_get_from_provider(&clkspec);
- orion_clkdev_add(NULL, "mv643xx_eth_port.1", clk);
- clk_prepare_enable(clk);
}

static void __init kirkwood_of_clk_init(void)
--
1.7.2.5
David Miller
2013-05-06 15:38:00 UTC
Permalink
Two things:

1) None of your postings make the mailing lists because your CC: line is
too large, and we block large ones because those are %99 of SPAM.

It really isn't reasonable to CC: so many people, and I do understand
that you're just sifting email addresses from MAINTAINERS or whatever,
but just use the appropriate mailing lists and the absolute most direct
developer(s). Probably just the person who you believe should apply
this patch.

2) Networking feature patch submissions are closed, as per:

http://marc.info/?l=linux-netdev&m=136730964130303&w=2

Therefore please resubmit this after the merge window is closed
and I have explicitly announced that the net-next tree is open again
for submissions.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jason Cooper
2013-05-06 16:07:43 UTC
Permalink
Sebastian,
Post by Sebastian Hesselbarth
This patch set picks up work by Florian Fainelli bringing full DT
support to mv643xx_eth and Marvell SoCs using it.
The current patch set drops Florian's device tree conversions for
Kirkwood, Dove, and Orion5x in favour of split patches for board
files and board descriptor files.
Device tree conversion for Dove and Kirkwood is added. Dove has
been fully tested, while Kirkwood is compile-tested only.
net: mv643xx_eth: add Device Tree bindings
net: mv643xx_eth: update Device Tree bindings documentation
Obviously, these will go through -net once the submission window opens.
(reordered for clarity)
Post by Sebastian Hesselbarth
ARM: dove: remove legacy mv643xx_eth setup
ARM: kirkwood: remove legacy mv643xx_eth board setup
ARM: kirkwood: remove legacy clk alias for mv643xx_eth
mvebu/boards or /soc.
Post by Sebastian Hesselbarth
ARM: kirkwood: add gigabit ethernet and mvmdio device tree nodes
ARM: dove: add gigabit ethernet and mvmdio device tree nodes
mvebu/dt


mvebu/dt and -net are fine. They have no dependencies. The problem is
mvebu/boards. To boot with networking, it needs -net *and* mvebu/dt.
Otherwise, the board needs to do legacy init.

I'd like to attempt to remove this dependency-hell with code. eg some
quick pseudo-code:

if (!dt_node_present("marvell,mv643xx_eth") ||
!mvebu_dt_bindings_present())
kirkwood_ge00_init();

The advantages of figuring this out are:
- *no* branch dependencies
- whole conversion done in one merge window

The drawbacks:
- need to remember to do a follow-on patch if all branches are
successfuly merged, removing the unneeded logic (after -rc1)
- considered churn?

The easy answer is to merge mvebu/dt, and -net, wait one cycle, and
merge the board stuff as you have it now (with Thomas' comment).

If we can figure this out, I'd like to do the same for the kirkwood-pcie
series.

thoughts?

thx,

Jason.
Sebastian Hesselbarth
2013-05-06 16:21:54 UTC
Permalink
Post by Florian Fainelli
Sebastian,
Post by Sebastian Hesselbarth
This patch set picks up work by Florian Fainelli bringing full DT
support to mv643xx_eth and Marvell SoCs using it.
The current patch set drops Florian's device tree conversions for
Kirkwood, Dove, and Orion5x in favour of split patches for board
files and board descriptor files.
Device tree conversion for Dove and Kirkwood is added. Dove has
been fully tested, while Kirkwood is compile-tested only.
net: mv643xx_eth: add Device Tree bindings
net: mv643xx_eth: update Device Tree bindings documentation
Obviously, these will go through -net once the submission window opens.
(reordered for clarity)
Post by Sebastian Hesselbarth
ARM: dove: remove legacy mv643xx_eth setup
ARM: kirkwood: remove legacy mv643xx_eth board setup
ARM: kirkwood: remove legacy clk alias for mv643xx_eth
mvebu/boards or /soc.
Post by Sebastian Hesselbarth
ARM: kirkwood: add gigabit ethernet and mvmdio device tree nodes
ARM: dove: add gigabit ethernet and mvmdio device tree nodes
mvebu/dt
mvebu/dt and -net are fine. They have no dependencies. The problem is
mvebu/boards. To boot with networking, it needs -net *and* mvebu/dt.
Otherwise, the board needs to do legacy init.
I'd like to attempt to remove this dependency-hell with code. eg some
if (!dt_node_present("marvell,mv643xx_eth") ||
!mvebu_dt_bindings_present())
kirkwood_ge00_init();
- *no* branch dependencies
- whole conversion done in one merge window
- need to remember to do a follow-on patch if all branches are
successfuly merged, removing the unneeded logic (after -rc1)
- considered churn?
The easy answer is to merge mvebu/dt, and -net, wait one cycle, and
merge the board stuff as you have it now (with Thomas' comment).
If we can figure this out, I'd like to do the same for the kirkwood-pcie
series.
Jason,

I suggest to take the "easy answer", i.e. merge mvebu/dt and -net and
take all board merges one cycle later.

Waiting for -net will stall irqchip but will give us enough time to
add DT timer and get rid of any legacy init code introduced for irqchip.
Also orion5x and mv78x00 can be added to mv643xx_eth conversion.

I am preparing empty board files removal as Thomas suggested.

Sebastian

P.S.: I was hoping that adding all people scripts/get_maintainers.pl
throws out, will notice all kirkwood board users ever committed to
mainline kernel. But as David Miller pointed out, it will not go through
SPAM filters that way. So have an eye open for v4 on mailing lists as
soon as -net merge window re-opens.
Valentin Longchamp
2013-05-07 09:10:24 UTC
Permalink
Sebastian,
Post by Sebastian Hesselbarth
This patch set picks up work by Florian Fainelli bringing full DT
support to mv643xx_eth and Marvell SoCs using it.
The current patch set drops Florian's device tree conversions for
Kirkwood, Dove, and Orion5x in favour of split patches for board
files and board descriptor files.
Device tree conversion for Dove and Kirkwood is added. Dove has
been fully tested, while Kirkwood is compile-tested only.
net: mv643xx_eth: add Device Tree bindings
net: mv643xx_eth: update Device Tree bindings documentation
ARM: dove: remove legacy mv643xx_eth setup
ARM: dove: add gigabit ethernet and mvmdio device tree nodes
ARM: kirkwood: remove legacy mv643xx_eth board setup
ARM: kirkwood: add gigabit ethernet and mvmdio device tree nodes
ARM: kirkwood: remove legacy clk alias for mv643xx_eth
I have successfully tested these patches on km_kirkwood, you can add my tested-by:

Tested-by: Valentin Longchamp<***@keymile.com>
Sebastian Hesselbarth
2013-05-21 16:41:46 UTC
Permalink
This patch adds mv643xx_eth and mvmdio device tree nodes for DT enabled
Orion5x boards. Phy nodes are also added with reg property set on a
per-board basis.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Changelog:
v3->v4:
- convert to new device tree binding

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
.../dts/orion5x-lacie-ethernet-disk-mini-v2.dts | 17 ++++++++++++
arch/arm/boot/dts/orion5x.dtsi | 29 ++++++++++++++++++++
2 files changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/orion5x-lacie-ethernet-disk-mini-v2.dts b/arch/arm/boot/dts/orion5x-lacie-ethernet-disk-mini-v2.dts
index 0077fc8..c7e2efd 100644
--- a/arch/arm/boot/dts/orion5x-lacie-ethernet-disk-mini-v2.dts
+++ b/arch/arm/boot/dts/orion5x-lacie-ethernet-disk-mini-v2.dts
@@ -53,3 +53,20 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ &ethphy: ethernet-phy {
+ device-type = "ethernet-phy";
+ reg = <8>;
+ };
+};
+
+&eth {
+ status = "okay";
+
+ ethernet-***@0 {
+ phy-handle = <&ethphy>;
+ };
+};
diff --git a/arch/arm/boot/dts/orion5x.dtsi b/arch/arm/boot/dts/orion5x.dtsi
index 892c64e..6fe45d5 100644
--- a/arch/arm/boot/dts/orion5x.dtsi
+++ b/arch/arm/boot/dts/orion5x.dtsi
@@ -132,5 +132,34 @@
interrupts = <28>;
status = "okay";
};
+
+ mdio: mdio-***@72004 {
+ compatible = "marvell,orion-mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72004 0x84>;
+ interrupts = <22>;
+ status = "disabled";
+
+ /* add phy nodes in board file */
+ };
+
+ eth: ethernet-***@72000 {
+ compatible = "marvell,orion-eth";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72000 0x4000>;
+ marvell,tx-checksum-limit = <1600>;
+ status = "disabled";
+
+ ethernet-***@0 {
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg = <0>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
+ /* set phy-handle property in board file */
+ };
+ };
};
};
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:39 UTC
Permalink
Using a separated mdio bus driver with mvmdio, phy_detach on network device
removal will not stop the phy and finally lead to NULL pointer dereference
in mvmdio due to non-existent network device. Use phy_disconnect instead
to properly stop phy device from accessing network device prior removal of
the network device.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Note: I observed this behavior when removing a modular mv643xx_eth driver
after attaching it to a phy handled by (also modular) mvmdio. The mvmdio
conversion has been done in

commit c3a07134e6aa5b93a37f72ffa3d11fadf72bf757
("mv643xx_eth: convert to use the Marvell Orion MDIO driver")

and should go back any -stable version with that commit (propably only 3.9)

@David: I am not sure if the above description is sufficient for a -stable
patch, if you need more, like actual kernel failure, I am sure I can reproduce
it.

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index d0afeea..ef3454c 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2805,7 +2805,7 @@ static int mv643xx_eth_remove(struct platform_device *pdev)

unregister_netdev(mp->dev);
if (mp->phy != NULL)
- phy_detach(mp->phy);
+ phy_disconnect(mp->phy);
cancel_work_sync(&mp->tx_timeout_task);

if (!IS_ERR(mp->clk))
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:49 UTC
Permalink
With DT support for mv643xx_eth, board specific init for some boards now
is unneccessary. Remove those board files, Kconfig entries, and
corresponding entries in kirkwood_defconfig.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Note: board-km_kirkwood.c is also removed, as Valentin Longchamp confirmed
the lock-up is not caused by accessing clock gating registers but rather
non-existent device registers. This will be addressed by dtsi separation
for kirkwood and bobcat SoC variants.

Changelog:
v3->v4:
- remove more boards that don't require board specific setup

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/configs/kirkwood_defconfig | 16 ----
arch/arm/mach-kirkwood/Kconfig | 117 -------------------------
arch/arm/mach-kirkwood/Makefile | 16 ----
arch/arm/mach-kirkwood/board-dnskw.c | 7 --
arch/arm/mach-kirkwood/board-dockstar.c | 32 -------
arch/arm/mach-kirkwood/board-dreamplug.c | 35 --------
arch/arm/mach-kirkwood/board-dt.c | 38 --------
arch/arm/mach-kirkwood/board-goflexnet.c | 34 -------
arch/arm/mach-kirkwood/board-guruplug.c | 33 -------
arch/arm/mach-kirkwood/board-ib62x0.c | 29 ------
arch/arm/mach-kirkwood/board-iconnect.c | 10 ---
arch/arm/mach-kirkwood/board-iomega_ix2_200.c | 34 -------
arch/arm/mach-kirkwood/board-km_kirkwood.c | 44 ----------
arch/arm/mach-kirkwood/board-lsxl.c | 16 ----
arch/arm/mach-kirkwood/board-mplcec4.c | 14 ---
arch/arm/mach-kirkwood/board-ns2.c | 35 --------
arch/arm/mach-kirkwood/board-openblocks_a6.c | 26 ------
arch/arm/mach-kirkwood/board-readynas.c | 6 --
arch/arm/mach-kirkwood/board-ts219.c | 13 ---
arch/arm/mach-kirkwood/board-usi_topkick.c | 29 ------
20 files changed, 584 deletions(-)
delete mode 100644 arch/arm/mach-kirkwood/board-dockstar.c
delete mode 100644 arch/arm/mach-kirkwood/board-dreamplug.c
delete mode 100644 arch/arm/mach-kirkwood/board-goflexnet.c
delete mode 100644 arch/arm/mach-kirkwood/board-guruplug.c
delete mode 100644 arch/arm/mach-kirkwood/board-ib62x0.c
delete mode 100644 arch/arm/mach-kirkwood/board-iomega_ix2_200.c
delete mode 100644 arch/arm/mach-kirkwood/board-km_kirkwood.c
delete mode 100644 arch/arm/mach-kirkwood/board-ns2.c
delete mode 100644 arch/arm/mach-kirkwood/board-openblocks_a6.c
delete mode 100644 arch/arm/mach-kirkwood/board-usi_topkick.c

diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig
index a1d8252..540ca51 100644
--- a/arch/arm/configs/kirkwood_defconfig
+++ b/arch/arm/configs/kirkwood_defconfig
@@ -30,27 +30,11 @@ CONFIG_MACH_SHEEVAPLUG=y
CONFIG_MACH_T5325=y
CONFIG_MACH_TS219=y
CONFIG_MACH_TS41X=y
-CONFIG_MACH_CLOUDBOX_DT=y
CONFIG_MACH_DLINK_KIRKWOOD_DT=y
-CONFIG_MACH_DOCKSTAR_DT=y
-CONFIG_MACH_DREAMPLUG_DT=y
-CONFIG_MACH_GOFLEXNET_DT=y
-CONFIG_MACH_GURUPLUG_DT=y
-CONFIG_MACH_IB62X0_DT=y
-CONFIG_MACH_ICONNECT_DT=y
-CONFIG_MACH_INETSPACE_V2_DT=y
-CONFIG_MACH_IOMEGA_IX2_200_DT=y
-CONFIG_MACH_KM_KIRKWOOD_DT=y
CONFIG_MACH_LSXL_DT=y
CONFIG_MACH_MPLCEC4_DT=y
-CONFIG_MACH_NETSPACE_LITE_V2_DT=y
-CONFIG_MACH_NETSPACE_MAX_V2_DT=y
-CONFIG_MACH_NETSPACE_MINI_V2_DT=y
-CONFIG_MACH_NETSPACE_V2_DT=y
CONFIG_MACH_NSA310_DT=y
-CONFIG_MACH_OPENBLOCKS_A6_DT=y
CONFIG_MACH_READYNAS_DT=y
-CONFIG_MACH_TOPKICK_DT=y
CONFIG_MACH_TS219_DT=y
# CONFIG_CPU_FEROCEON_OLD_ID is not set
CONFIG_PREEMPT=y
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 7509a89..c2fd30b 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -146,13 +146,6 @@ config ARCH_KIRKWOOD_DT
Say 'Y' here if you want your kernel to support the
Marvell Kirkwood using flattened device tree.

-config MACH_CLOUDBOX_DT
- bool "LaCie CloudBox NAS (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the LaCie
- CloudBox NAS, using Flattened Device Tree.
-
config MACH_DLINK_KIRKWOOD_DT
bool "D-Link Kirkwood-based NAS (Flattened Device Tree)"
select ARCH_KIRKWOOD_DT
@@ -161,69 +154,6 @@ config MACH_DLINK_KIRKWOOD_DT
Kirkwood-based D-Link NASes such as DNS-320 & DNS-325,
using Flattened Device Tree.

-config MACH_DOCKSTAR_DT
- bool "Seagate FreeAgent Dockstar (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Seagate FreeAgent Dockstar (Flattened Device Tree).
-
-config MACH_DREAMPLUG_DT
- bool "Marvell DreamPlug (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Marvell DreamPlug (Flattened Device Tree).
-
-config MACH_GOFLEXNET_DT
- bool "Seagate GoFlex Net (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Seagate GoFlex Net (Flattened Device Tree).
-
-config MACH_GURUPLUG_DT
- bool "Marvell GuruPlug Reference Board (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Marvell GuruPlug Reference Board (Flattened Device Tree).
-
-config MACH_IB62X0_DT
- bool "RaidSonic IB-NAS6210, IB-NAS6220 (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- RaidSonic IB-NAS6210 & IB-NAS6220 devices, using
- Flattened Device Tree.
-
-config MACH_ICONNECT_DT
- bool "Iomega Iconnect (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here to enable Iomega Iconnect support.
-
-config MACH_INETSPACE_V2_DT
- bool "LaCie Internet Space v2 NAS (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the LaCie
- Internet Space v2 NAS, using Flattened Device Tree.
-
-config MACH_IOMEGA_IX2_200_DT
- bool "Iomega StorCenter ix2-200 (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Iomega StorCenter ix2-200 (Flattened Device Tree).
-
-config MACH_KM_KIRKWOOD_DT
- bool "Keymile Kirkwood Reference Design (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Keymile Kirkwood Reference Desgin, using Flattened Device Tree.
-
config MACH_LSXL_DT
bool "Buffalo Linkstation LS-XHL, LS-CHLv2 (Flattened Device Tree)"
select ARCH_KIRKWOOD_DT
@@ -239,39 +169,6 @@ config MACH_MPLCEC4_DT
Say 'Y' here if you want your kernel to support the
MPL CEC4 (Flattened Device Tree).

-config MACH_NETSPACE_LITE_V2_DT
- bool "LaCie Network Space Lite v2 NAS (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the LaCie
- Network Space Lite v2 NAS, using Flattened Device Tree.
-
-config MACH_NETSPACE_MAX_V2_DT
- bool "LaCie Network Space Max v2 NAS (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the LaCie
- Network Space Max v2 NAS, using Flattened Device Tree.
-
-config MACH_NETSPACE_MINI_V2_DT
- bool "LaCie Network Space Mini v2 NAS (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the LaCie
- Network Space Mini v2 NAS using Flattened Device Tree.
-
- This board is embedded in a product named CloudBox, which
- provides automatic backup on a 100GB cloud storage. This
- should not confused with a more recent LaCie NAS also named
- CloudBox. For this last, the disk capacity is 1TB or above.
-
-config MACH_NETSPACE_V2_DT
- bool "LaCie Network Space v2 NAS (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the LaCie
- Network Space v2 NAS, using Flattened Device Tree.
-
config MACH_NSA310_DT
bool "ZyXEL NSA-310 (Flattened Device Tree)"
select ARCH_KIRKWOOD_DT
@@ -280,13 +177,6 @@ config MACH_NSA310_DT
Say 'Y' here if you want your kernel to support the
ZyXEL NSA-310 board (Flattened Device Tree).

-config MACH_OPENBLOCKS_A6_DT
- bool "Plat'Home OpenBlocks A6 (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- Plat'Home OpenBlocks A6 (Flattened Device Tree).
-
config MACH_READYNAS_DT
bool "NETGEAR ReadyNAS Duo v2 (Flattened Device Tree)"
select ARCH_KIRKWOOD_DT
@@ -296,13 +186,6 @@ config MACH_READYNAS_DT
Say 'Y' here if you want your kernel to support the
NETGEAR ReadyNAS Duo v2 using Fattened Device Tree.

-config MACH_TOPKICK_DT
- bool "USI Topkick (Flattened Device Tree)"
- select ARCH_KIRKWOOD_DT
- help
- Say 'Y' here if you want your kernel to support the
- USI Topkick, using Flattened Device Tree
-
config MACH_TS219_DT
bool "Device Tree for QNAP TS-11X, TS-21X NAS"
select ARCH_KIRKWOOD_DT
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index e1f3735..8e7fa4f 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -20,25 +20,9 @@ obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o
obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o

obj-$(CONFIG_ARCH_KIRKWOOD_DT) += board-dt.o
-obj-$(CONFIG_MACH_CLOUDBOX_DT) += board-ns2.o
obj-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += board-dnskw.o
-obj-$(CONFIG_MACH_DOCKSTAR_DT) += board-dockstar.o
-obj-$(CONFIG_MACH_DREAMPLUG_DT) += board-dreamplug.o
-obj-$(CONFIG_MACH_GOFLEXNET_DT) += board-goflexnet.o
-obj-$(CONFIG_MACH_GURUPLUG_DT) += board-guruplug.o
-obj-$(CONFIG_MACH_IB62X0_DT) += board-ib62x0.o
-obj-$(CONFIG_MACH_ICONNECT_DT) += board-iconnect.o
-obj-$(CONFIG_MACH_INETSPACE_V2_DT) += board-ns2.o
-obj-$(CONFIG_MACH_IOMEGA_IX2_200_DT) += board-iomega_ix2_200.o
-obj-$(CONFIG_MACH_KM_KIRKWOOD_DT) += board-km_kirkwood.o
obj-$(CONFIG_MACH_LSXL_DT) += board-lsxl.o
obj-$(CONFIG_MACH_MPLCEC4_DT) += board-mplcec4.o
-obj-$(CONFIG_MACH_NETSPACE_LITE_V2_DT) += board-ns2.o
-obj-$(CONFIG_MACH_NETSPACE_MAX_V2_DT) += board-ns2.o
-obj-$(CONFIG_MACH_NETSPACE_MINI_V2_DT) += board-ns2.o
-obj-$(CONFIG_MACH_NETSPACE_V2_DT) += board-ns2.o
obj-$(CONFIG_MACH_NSA310_DT) += board-nsa310.o
-obj-$(CONFIG_MACH_OPENBLOCKS_A6_DT) += board-openblocks_a6.o
obj-$(CONFIG_MACH_READYNAS_DT) += board-readynas.o
-obj-$(CONFIG_MACH_TOPKICK_DT) += board-usi_topkick.o
obj-$(CONFIG_MACH_TS219_DT) += board-ts219.o tsx1x-common.o
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index a1aa87f..2af7a95 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -14,14 +14,9 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <linux/gpio.h>
#include "common.h"

-static struct mv643xx_eth_platform_data dnskw_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
/* Register any GPIO for output and set the value */
static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
{
@@ -36,8 +31,6 @@ static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)

void __init dnskw_init(void)
{
- kirkwood_ge00_init(&dnskw_ge00_data);
-
/* Set NAS to turn back on after a power failure */
dnskw_gpio_register(37, "dnskw:power:recover", 1);
}
diff --git a/arch/arm/mach-kirkwood/board-dockstar.c b/arch/arm/mach-kirkwood/board-dockstar.c
deleted file mode 100644
index d7196db..0000000
--- a/arch/arm/mach-kirkwood/board-dockstar.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * arch/arm/mach-kirkwood/board-dockstar.c
- *
- * Seagate FreeAgent Dockstar Board Init for drivers not converted to
- * flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- *
- * Copied and modified for Seagate GoFlex Net support by
- * Joshua Coombs <***@gmail.com> based on ArchLinux ARM's
- * GoFlex kernel patches.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data dockstar_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-void __init dockstar_dt_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&dockstar_ge00_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-dreamplug.c b/arch/arm/mach-kirkwood/board-dreamplug.c
deleted file mode 100644
index 0903242..0000000
--- a/arch/arm/mach-kirkwood/board-dreamplug.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2012 (C), Jason Cooper <***@lakedaemon.net>
- *
- * arch/arm/mach-kirkwood/board-dreamplug.c
- *
- * Marvell DreamPlug Reference Board Init for drivers not converted to
- * flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data dreamplug_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(1),
-};
-
-void __init dreamplug_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&dreamplug_ge00_data);
- kirkwood_ge01_init(&dreamplug_ge01_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 8db388a..a86b41c 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -104,59 +104,21 @@ static void __init kirkwood_dt_init(void)
kexec_reinit = kirkwood_enable_pcie;
#endif

- if (of_machine_is_compatible("globalscale,dreamplug"))
- dreamplug_init();
-
- if (of_machine_is_compatible("globalscale,guruplug"))
- guruplug_dt_init();
-
if (of_machine_is_compatible("dlink,dns-kirkwood"))
dnskw_init();

- if (of_machine_is_compatible("iom,iconnect"))
- iconnect_init();
-
- if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
- ib62x0_init();
-
if (of_machine_is_compatible("qnap,ts219"))
qnap_dt_ts219_init();

- if (of_machine_is_compatible("seagate,dockstar"))
- dockstar_dt_init();
-
- if (of_machine_is_compatible("seagate,goflexnet"))
- goflexnet_init();
-
if (of_machine_is_compatible("buffalo,lsxl"))
lsxl_init();

- if (of_machine_is_compatible("iom,ix2-200"))
- iomega_ix2_200_init();
-
- if (of_machine_is_compatible("keymile,km_kirkwood"))
- km_kirkwood_init();
-
- if (of_machine_is_compatible("lacie,cloudbox") ||
- of_machine_is_compatible("lacie,inetspace_v2") ||
- of_machine_is_compatible("lacie,netspace_lite_v2") ||
- of_machine_is_compatible("lacie,netspace_max_v2") ||
- of_machine_is_compatible("lacie,netspace_mini_v2") ||
- of_machine_is_compatible("lacie,netspace_v2"))
- ns2_init();
-
if (of_machine_is_compatible("mpl,cec4"))
mplcec4_init();

if (of_machine_is_compatible("netgear,readynas-duo-v2"))
netgear_readynas_init();

- if (of_machine_is_compatible("plathome,openblocks-a6"))
- openblocks_a6_init();
-
- if (of_machine_is_compatible("usi,topkick"))
- usi_topkick_init();
-
of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
}

diff --git a/arch/arm/mach-kirkwood/board-goflexnet.c b/arch/arm/mach-kirkwood/board-goflexnet.c
deleted file mode 100644
index 9db979a..0000000
--- a/arch/arm/mach-kirkwood/board-goflexnet.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2012 (C), Jason Cooper <***@lakedaemon.net>
- *
- * arch/arm/mach-kirkwood/board-goflexnet.c
- *
- * Seagate GoFlext Net Board Init for drivers not converted to
- * flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- *
- * Copied and modified for Seagate GoFlex Net support by
- * Joshua Coombs <***@gmail.com> based on ArchLinux ARM's
- * GoFlex kernel patches.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data goflexnet_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-void __init goflexnet_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&goflexnet_ge00_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-guruplug.c b/arch/arm/mach-kirkwood/board-guruplug.c
deleted file mode 100644
index a857163..0000000
--- a/arch/arm/mach-kirkwood/board-guruplug.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * arch/arm/mach-kirkwood/board-guruplug.c
- *
- * Marvell Guruplug Reference Board Init for drivers not converted to
- * flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data guruplug_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data guruplug_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(1),
-};
-
-void __init guruplug_dt_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&guruplug_ge00_data);
- kirkwood_ge01_init(&guruplug_ge01_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c
deleted file mode 100644
index 9a857ae..0000000
--- a/arch/arm/mach-kirkwood/board-ib62x0.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2012 (C), Simon Baatz <***@gmail.com>
- *
- * arch/arm/mach-kirkwood/board-ib62x0.c
- *
- * RaidSonic ICY BOX IB-NAS6210 & IB-NAS6220 init for drivers not
- * converted to flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
-void __init ib62x0_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&ib62x0_ge00_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-iconnect.c b/arch/arm/mach-kirkwood/board-iconnect.c
index c8ebde4..fcaf136 100644
--- a/arch/arm/mach-kirkwood/board-iconnect.c
+++ b/arch/arm/mach-kirkwood/board-iconnect.c
@@ -11,18 +11,8 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/of.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data iconnect_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(11),
-};
-
-void __init iconnect_init(void)
-{
- kirkwood_ge00_init(&iconnect_ge00_data);
-}
-
static int __init iconnect_pci_init(void)
{
if (of_machine_is_compatible("iom,iconnect"))
diff --git a/arch/arm/mach-kirkwood/board-iomega_ix2_200.c b/arch/arm/mach-kirkwood/board-iomega_ix2_200.c
deleted file mode 100644
index e5f7041..0000000
--- a/arch/arm/mach-kirkwood/board-iomega_ix2_200.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * arch/arm/mach-kirkwood/board-iomega_ix2_200.c
- *
- * Iomega StorCenter ix2-200
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include <linux/ethtool.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data iomega_ix2_200_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_NONE,
- .speed = SPEED_1000,
- .duplex = DUPLEX_FULL,
-};
-
-static struct mv643xx_eth_platform_data iomega_ix2_200_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(11),
-};
-
-void __init iomega_ix2_200_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&iomega_ix2_200_ge00_data);
- kirkwood_ge01_init(&iomega_ix2_200_ge01_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-km_kirkwood.c b/arch/arm/mach-kirkwood/board-km_kirkwood.c
deleted file mode 100644
index 44e4605..0000000
--- a/arch/arm/mach-kirkwood/board-km_kirkwood.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2012 2012 KEYMILE AG, CH-3097 Bern
- * Valentin Longchamp <***@keymile.com>
- *
- * arch/arm/mach-kirkwood/board-km_kirkwood.c
- *
- * Keymile km_kirkwood Reference Desing Init for drivers not converted to
- * flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include <linux/clk.h>
-#include <linux/clk-private.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data km_kirkwood_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-void __init km_kirkwood_init(void)
-{
- struct clk *sata_clk;
- /*
- * Our variant of kirkwood (integrated in the Bobcat) hangs on accessing
- * SATA bits (14-15) of the Clock Gating Control Register. Since these
- * devices are also not present in this variant, their clocks get
- * disabled because unused when clk_disable_unused() gets called.
- * That's why we change the flags to these clocks to CLK_IGNORE_UNUSED
- */
- sata_clk = clk_get_sys("sata_mv.0", "0");
- if (!IS_ERR(sata_clk))
- sata_clk->flags |= CLK_IGNORE_UNUSED;
- sata_clk = clk_get_sys("sata_mv.0", "1");
- if (!IS_ERR(sata_clk))
- sata_clk->flags |= CLK_IGNORE_UNUSED;
-
- kirkwood_ge00_init(&km_kirkwood_ge00_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-lsxl.c b/arch/arm/mach-kirkwood/board-lsxl.c
index 4ec8b7a..3dc0929 100644
--- a/arch/arm/mach-kirkwood/board-lsxl.c
+++ b/arch/arm/mach-kirkwood/board-lsxl.c
@@ -14,17 +14,8 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data lsxl_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data lsxl_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
/*
* On the LS-XHL/LS-CHLv2, the shutdown process is following:
* - Userland monitors key events until the power switch goes to off position
@@ -40,13 +31,6 @@ static void lsxl_power_off(void)

void __init lsxl_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
-
- kirkwood_ge00_init(&lsxl_ge00_data);
- kirkwood_ge01_init(&lsxl_ge01_data);
-
/* register power-off method */
pm_power_off = lsxl_power_off;
}
diff --git a/arch/arm/mach-kirkwood/board-mplcec4.c b/arch/arm/mach-kirkwood/board-mplcec4.c
index 7d6dc66..dd1f655 100644
--- a/arch/arm/mach-kirkwood/board-mplcec4.c
+++ b/arch/arm/mach-kirkwood/board-mplcec4.c
@@ -11,24 +11,10 @@

#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
#include "common.h"

-static struct mv643xx_eth_platform_data mplcec4_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(1),
-};
-
-static struct mv643xx_eth_platform_data mplcec4_ge01_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(2),
-};
-
void __init mplcec4_init(void)
{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&mplcec4_ge00_data);
- kirkwood_ge01_init(&mplcec4_ge01_data);
kirkwood_pcie_init(KW_PCIE0);
}

diff --git a/arch/arm/mach-kirkwood/board-ns2.c b/arch/arm/mach-kirkwood/board-ns2.c
deleted file mode 100644
index f8f6605..0000000
--- a/arch/arm/mach-kirkwood/board-ns2.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2012 (C), Simon Guinot <***@sequanux.org>
- *
- * arch/arm/mach-kirkwood/board-ns2.c
- *
- * LaCie Network Space v2 board (and parents) initialization for drivers
- * not converted to flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
-#include <linux/of.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data ns2_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
-void __init ns2_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- if (of_machine_is_compatible("lacie,cloudbox") ||
- of_machine_is_compatible("lacie,netspace_lite_v2") ||
- of_machine_is_compatible("lacie,netspace_mini_v2"))
- ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
- kirkwood_ge00_init(&ns2_ge00_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-openblocks_a6.c b/arch/arm/mach-kirkwood/board-openblocks_a6.c
deleted file mode 100644
index b11d8fd..0000000
--- a/arch/arm/mach-kirkwood/board-openblocks_a6.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2012 Nobuhiro Iwamatsu <***@nigauri.org>
- *
- * arch/arm/mach-kirkwood/board-openblocks_a6.c
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data openblocks_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-void __init openblocks_a6_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&openblocks_ge00_data);
-}
diff --git a/arch/arm/mach-kirkwood/board-readynas.c b/arch/arm/mach-kirkwood/board-readynas.c
index fb42c20..3ab3e0e 100644
--- a/arch/arm/mach-kirkwood/board-readynas.c
+++ b/arch/arm/mach-kirkwood/board-readynas.c
@@ -13,16 +13,10 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <mach/kirkwood.h>
#include "common.h"

-static struct mv643xx_eth_platform_data netgear_readynas_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
void __init netgear_readynas_init(void)
{
- kirkwood_ge00_init(&netgear_readynas_ge00_data);
kirkwood_pcie_init(KW_PCIE0);
}
diff --git a/arch/arm/mach-kirkwood/board-ts219.c b/arch/arm/mach-kirkwood/board-ts219.c
index acb0187..854d448 100644
--- a/arch/arm/mach-kirkwood/board-ts219.c
+++ b/arch/arm/mach-kirkwood/board-ts219.c
@@ -18,27 +18,14 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <mach/kirkwood.h>
#include "common.h"
#include "tsx1x-common.h"

-static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(8),
-};
-
void __init qnap_dt_ts219_init(void)
{
- u32 dev, rev;
-
- kirkwood_pcie_id(&dev, &rev);
- if (dev == MV88F6282_DEV_ID)
- qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
-
- kirkwood_ge00_init(&qnap_ts219_ge00_data);
-
pm_power_off = qnap_tsx1x_power_off;
}

diff --git a/arch/arm/mach-kirkwood/board-usi_topkick.c b/arch/arm/mach-kirkwood/board-usi_topkick.c
deleted file mode 100644
index 1cc04ec..0000000
--- a/arch/arm/mach-kirkwood/board-usi_topkick.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2012 (C), Jason Cooper <***@lakedaemon.net>
- *
- * arch/arm/mach-kirkwood/board-usi_topkick.c
- *
- * USI Topkick Init for drivers not converted to flattened device tree yet.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/mv643xx_eth.h>
-#include <linux/gpio.h>
-#include "common.h"
-
-static struct mv643xx_eth_platform_data topkick_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR(0),
-};
-
-void __init usi_topkick_init(void)
-{
- /*
- * Basic setup. Needs to be called early.
- */
- kirkwood_ge00_init(&topkick_ge00_data);
-}
--
1.7.10.4
Simon Baatz
2013-05-22 20:36:33 UTC
Permalink
Hi Sebastian,
Post by Sebastian Hesselbarth
With DT support for mv643xx_eth, board specific init for some boards now
is unneccessary. Remove those board files, Kconfig entries, and
corresponding entries in kirkwood_defconfig.
---
Note: board-km_kirkwood.c is also removed, as Valentin Longchamp confirmed
the lock-up is not caused by accessing clock gating registers but rather
non-existent device registers. This will be addressed by dtsi separation
for kirkwood and bobcat SoC variants.
- remove more boards that don't require board specific setup
---
arch/arm/configs/kirkwood_defconfig | 16 ----
arch/arm/mach-kirkwood/Kconfig | 117 -------------------------
arch/arm/mach-kirkwood/Makefile | 16 ----
arch/arm/mach-kirkwood/board-dnskw.c | 7 --
arch/arm/mach-kirkwood/board-dockstar.c | 32 -------
arch/arm/mach-kirkwood/board-dreamplug.c | 35 --------
arch/arm/mach-kirkwood/board-dt.c | 38 --------
arch/arm/mach-kirkwood/board-goflexnet.c | 34 -------
arch/arm/mach-kirkwood/board-guruplug.c | 33 -------
arch/arm/mach-kirkwood/board-ib62x0.c | 29 ------
arch/arm/mach-kirkwood/board-iconnect.c | 10 ---
arch/arm/mach-kirkwood/board-iomega_ix2_200.c | 34 -------
arch/arm/mach-kirkwood/board-km_kirkwood.c | 44 ----------
arch/arm/mach-kirkwood/board-lsxl.c | 16 ----
arch/arm/mach-kirkwood/board-mplcec4.c | 14 ---
arch/arm/mach-kirkwood/board-ns2.c | 35 --------
arch/arm/mach-kirkwood/board-openblocks_a6.c | 26 ------
arch/arm/mach-kirkwood/board-readynas.c | 6 --
arch/arm/mach-kirkwood/board-ts219.c | 13 ---
arch/arm/mach-kirkwood/board-usi_topkick.c | 29 ------
20 files changed, 584 deletions(-)
delete mode 100644 arch/arm/mach-kirkwood/board-dockstar.c
delete mode 100644 arch/arm/mach-kirkwood/board-dreamplug.c
delete mode 100644 arch/arm/mach-kirkwood/board-goflexnet.c
delete mode 100644 arch/arm/mach-kirkwood/board-guruplug.c
delete mode 100644 arch/arm/mach-kirkwood/board-ib62x0.c
delete mode 100644 arch/arm/mach-kirkwood/board-iomega_ix2_200.c
delete mode 100644 arch/arm/mach-kirkwood/board-km_kirkwood.c
delete mode 100644 arch/arm/mach-kirkwood/board-ns2.c
delete mode 100644 arch/arm/mach-kirkwood/board-openblocks_a6.c
delete mode 100644 arch/arm/mach-kirkwood/board-usi_topkick.c
...
Post by Sebastian Hesselbarth
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 8db388a..a86b41c 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -104,59 +104,21 @@ static void __init kirkwood_dt_init(void)
kexec_reinit = kirkwood_enable_pcie;
#endif
- if (of_machine_is_compatible("globalscale,dreamplug"))
- dreamplug_init();
-
- if (of_machine_is_compatible("globalscale,guruplug"))
- guruplug_dt_init();
-
if (of_machine_is_compatible("dlink,dns-kirkwood"))
dnskw_init();
- if (of_machine_is_compatible("iom,iconnect"))
- iconnect_init();
-
- if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
- ib62x0_init();
-
if (of_machine_is_compatible("qnap,ts219"))
qnap_dt_ts219_init();
- if (of_machine_is_compatible("seagate,dockstar"))
- dockstar_dt_init();
-
- if (of_machine_is_compatible("seagate,goflexnet"))
- goflexnet_init();
-
if (of_machine_is_compatible("buffalo,lsxl"))
lsxl_init();
- if (of_machine_is_compatible("iom,ix2-200"))
- iomega_ix2_200_init();
-
- if (of_machine_is_compatible("keymile,km_kirkwood"))
- km_kirkwood_init();
-
- if (of_machine_is_compatible("lacie,cloudbox") ||
- of_machine_is_compatible("lacie,inetspace_v2") ||
- of_machine_is_compatible("lacie,netspace_lite_v2") ||
- of_machine_is_compatible("lacie,netspace_max_v2") ||
- of_machine_is_compatible("lacie,netspace_mini_v2") ||
- of_machine_is_compatible("lacie,netspace_v2"))
- ns2_init();
-
if (of_machine_is_compatible("mpl,cec4"))
mplcec4_init();
if (of_machine_is_compatible("netgear,readynas-duo-v2"))
netgear_readynas_init();
- if (of_machine_is_compatible("plathome,openblocks-a6"))
- openblocks_a6_init();
-
- if (of_machine_is_compatible("usi,topkick"))
- usi_topkick_init();
-
of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
}
We still have:

static const char * const kirkwood_dt_board_compat[] = {
"globalscale,dreamplug",
"globalscale,guruplug",
"dlink,dns-320",
"dlink,dns-325",
"iom,iconnect",
"raidsonic,ib-nas62x0",
"qnap,ts219",
"seagate,dockstar",
"seagate,goflexnet",
"buffalo,lsxl",
"iom,ix2-200",
"keymile,km_kirkwood",
"lacie,cloudbox",
"lacie,inetspace_v2",
"lacie,netspace_lite_v2",
"lacie,netspace_max_v2",
"lacie,netspace_mini_v2",
"lacie,netspace_v2",
"mpl,cec4",
"netgear,readynas-duo-v2",
"plathome,openblocks-a6",
"usi,topkick",
"zyxel,nsa310",
NULL
};

in that file. I think it does not make sense that we need to list
boards here that can be described fully by DT. When adding such a
board in the future, you will still need to adapt board-dt.c.

Should we remove the boards that you removed above here as well and
add

"marvell,kirkwood-88f6192",
"marvell,kirkwood-88f6281",
"marvell,kirkwood-88f6282",
"marvell,kirkwood-88f6283",
"marvell,kirkwood-88f6702",
"marvell,kirkwood-98DX4122",

or even just state "marvell,kirkwood"?

- Simon
Sebastian Hesselbarth
2013-05-22 20:55:43 UTC
Permalink
Post by Simon Baatz
Hi Sebastian,
Post by Sebastian Hesselbarth
With DT support for mv643xx_eth, board specific init for some boards now
is unneccessary. Remove those board files, Kconfig entries, and
corresponding entries in kirkwood_defconfig.
---
Note: board-km_kirkwood.c is also removed, as Valentin Longchamp confirmed
the lock-up is not caused by accessing clock gating registers but rather
non-existent device registers. This will be addressed by dtsi separation
for kirkwood and bobcat SoC variants.
- remove more boards that don't require board specific setup
...
Post by Simon Baatz
static const char * const kirkwood_dt_board_compat[] = {
"globalscale,dreamplug",
"globalscale,guruplug",
"dlink,dns-320",
"dlink,dns-325",
"iom,iconnect",
"raidsonic,ib-nas62x0",
"qnap,ts219",
"seagate,dockstar",
"seagate,goflexnet",
"buffalo,lsxl",
"iom,ix2-200",
"keymile,km_kirkwood",
"lacie,cloudbox",
"lacie,inetspace_v2",
"lacie,netspace_lite_v2",
"lacie,netspace_max_v2",
"lacie,netspace_mini_v2",
"lacie,netspace_v2",
"mpl,cec4",
"netgear,readynas-duo-v2",
"plathome,openblocks-a6",
"usi,topkick",
"zyxel,nsa310",
NULL
};
in that file. I think it does not make sense that we need to list
boards here that can be described fully by DT. When adding such a
board in the future, you will still need to adapt board-dt.c.
True, will remove the redundant compatible strings for v5.
Actually, if I am not missing something, all compatible strings except
"marvell,kirkwood" are redundant as long as board.dts append it
correctly.
Post by Simon Baatz
Should we remove the boards that you removed above here as well and
add
"marvell,kirkwood-88f6192",
"marvell,kirkwood-88f6281",
"marvell,kirkwood-88f6282",
"marvell,kirkwood-88f6283",
"marvell,kirkwood-88f6702",
"marvell,kirkwood-98DX4122",
or even just state "marvell,kirkwood"?
I would stick with "marvell,kirkwood" only. This is SoC init code and
we do not distinguish variants here at all.

Sebastian
Jason Cooper
2013-05-22 21:02:57 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Simon Baatz
Hi Sebastian,
Post by Sebastian Hesselbarth
With DT support for mv643xx_eth, board specific init for some boards now
is unneccessary. Remove those board files, Kconfig entries, and
corresponding entries in kirkwood_defconfig.
---
Note: board-km_kirkwood.c is also removed, as Valentin Longchamp confirmed
the lock-up is not caused by accessing clock gating registers but rather
non-existent device registers. This will be addressed by dtsi separation
for kirkwood and bobcat SoC variants.
- remove more boards that don't require board specific setup
...
Post by Simon Baatz
static const char * const kirkwood_dt_board_compat[] = {
"globalscale,dreamplug",
"globalscale,guruplug",
"dlink,dns-320",
"dlink,dns-325",
"iom,iconnect",
"raidsonic,ib-nas62x0",
"qnap,ts219",
"seagate,dockstar",
"seagate,goflexnet",
"buffalo,lsxl",
"iom,ix2-200",
"keymile,km_kirkwood",
"lacie,cloudbox",
"lacie,inetspace_v2",
"lacie,netspace_lite_v2",
"lacie,netspace_max_v2",
"lacie,netspace_mini_v2",
"lacie,netspace_v2",
"mpl,cec4",
"netgear,readynas-duo-v2",
"plathome,openblocks-a6",
"usi,topkick",
"zyxel,nsa310",
NULL
};
in that file. I think it does not make sense that we need to list
boards here that can be described fully by DT. When adding such a
board in the future, you will still need to adapt board-dt.c.
True, will remove the redundant compatible strings for v5.
Actually, if I am not missing something, all compatible strings except
"marvell,kirkwood" are redundant as long as board.dts append it
correctly.
Post by Simon Baatz
Should we remove the boards that you removed above here as well and
add
"marvell,kirkwood-88f6192",
"marvell,kirkwood-88f6281",
"marvell,kirkwood-88f6282",
"marvell,kirkwood-88f6283",
"marvell,kirkwood-88f6702",
"marvell,kirkwood-98DX4122",
or even just state "marvell,kirkwood"?
I would stick with "marvell,kirkwood" only. This is SoC init code and
we do not distinguish variants here at all.
Agreed, nice catch Simon.

thx,

Jason.
Sebastian Hesselbarth
2013-05-22 21:17:46 UTC
Permalink
Post by Jason Cooper
Post by Sebastian Hesselbarth
Post by Simon Baatz
Hi Sebastian,
Post by Sebastian Hesselbarth
With DT support for mv643xx_eth, board specific init for some boards now
is unneccessary. Remove those board files, Kconfig entries, and
corresponding entries in kirkwood_defconfig.
---
Note: board-km_kirkwood.c is also removed, as Valentin Longchamp confirmed
the lock-up is not caused by accessing clock gating registers but rather
non-existent device registers. This will be addressed by dtsi separation
for kirkwood and bobcat SoC variants.
- remove more boards that don't require board specific setup
...
I would stick with "marvell,kirkwood" only. This is SoC init code and
we do not distinguish variants here at all.
Agreed, nice catch Simon.
I just confirmed all kirkwood dts/dtsi properly set "marvell,kirkwood"
in their compatible strings. Will remove all other comapatible strings
from mach-kirkwood/board-dt.c as Simon suggested for v5.

Sebastian
Sebastian Hesselbarth
2013-05-21 16:41:50 UTC
Permalink
With DT support for mv643xx_eth we do not need legacy platform_data
based setup for DT enabled boards. This patch removes eth setup
for all orion5x DT board files.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/mach-orion5x/edmini_v2-setup.c | 10 ----------
1 file changed, 10 deletions(-)

diff --git a/arch/arm/mach-orion5x/edmini_v2-setup.c b/arch/arm/mach-orion5x/edmini_v2-setup.c
index 1476155..d9de926 100644
--- a/arch/arm/mach-orion5x/edmini_v2-setup.c
+++ b/arch/arm/mach-orion5x/edmini_v2-setup.c
@@ -24,7 +24,6 @@
#include <linux/pci.h>
#include <linux/irq.h>
#include <linux/mtd/physmap.h>
-#include <linux/mv643xx_eth.h>
#include <linux/leds.h>
#include <linux/gpio_keys.h>
#include <linux/input.h>
@@ -96,14 +95,6 @@ static struct platform_device edmini_v2_nor_flash = {
};

/*****************************************************************************
- * Ethernet
- ****************************************************************************/
-
-static struct mv643xx_eth_platform_data edmini_v2_eth_data = {
- .phy_addr = 8,
-};
-
-/*****************************************************************************
* RTC 5C372a on I2C bus
****************************************************************************/

@@ -152,7 +143,6 @@ void __init edmini_v2_init(void)
* Configure peripherals.
*/
orion5x_ehci0_init();
- orion5x_eth_init(&edmini_v2_eth_data);

mvebu_mbus_add_window("devbus-boot", EDMINI_V2_NOR_BOOT_BASE,
EDMINI_V2_NOR_BOOT_SIZE);
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:44 UTC
Permalink
This patch adds orion-eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to set its reg property on a per-board
basis.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Changelog:
v3->v4:
- convert to new device tree binding

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/boot/dts/dove-cubox.dts | 7 +++++++
arch/arm/boot/dts/dove.dtsi | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)

diff --git a/arch/arm/boot/dts/dove-cubox.dts b/arch/arm/boot/dts/dove-cubox.dts
index 7e3065a..02618fa 100644
--- a/arch/arm/boot/dts/dove-cubox.dts
+++ b/arch/arm/boot/dts/dove-cubox.dts
@@ -49,6 +49,13 @@
&uart0 { status = "okay"; };
&sata0 { status = "okay"; };
&i2c0 { status = "okay"; };
+&mdio { status = "okay"; };
+&eth { status = "okay"; };
+
+&ethphy {
+ compatible = "marvell,88e1310";
+ reg = <1>;
+};

&sdio0 {
status = "okay";
diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index 6cab468..8612658 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -258,5 +258,40 @@
dmacap,xor;
};
};
+
+ mdio: mdio-***@72004 {
+ compatible = "marvell,orion-mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72004 0x84>;
+ interrupts = <30>;
+ clocks = <&gate_clk 2>;
+ status = "disabled";
+
+ ethphy: ethernet-phy {
+ device-type = "ethernet-phy";
+ /* set phy address in board file */
+ };
+ };
+
+ eth: ethernet-***@72000 {
+ compatible = "marvell,orion-eth";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72000 0x4000>;
+ clocks = <&gate_clk 2>;
+ marvell,tx-checksum-limit = <1600>;
+ status = "disabled";
+
+ ethernet-***@0 {
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg = <0>;
+ interrupts = <29>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
+ phy-handle = <&ethphy>;
+ };
+ };
};
};
--
1.7.10.4
Andrew Lunn
2013-05-21 17:48:49 UTC
Permalink
Post by Sebastian Hesselbarth
This patch adds orion-eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to set its reg property on a per-board
basis.
---
- convert to new device tree binding
---
arch/arm/boot/dts/dove-cubox.dts | 7 +++++++
arch/arm/boot/dts/dove.dtsi | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/arch/arm/boot/dts/dove-cubox.dts b/arch/arm/boot/dts/dove-cubox.dts
index 7e3065a..02618fa 100644
--- a/arch/arm/boot/dts/dove-cubox.dts
+++ b/arch/arm/boot/dts/dove-cubox.dts
@@ -49,6 +49,13 @@
&uart0 { status = "okay"; };
&sata0 { status = "okay"; };
&i2c0 { status = "okay"; };
+&mdio { status = "okay"; };
+&eth { status = "okay"; };
+
+&ethphy {
+ compatible = "marvell,88e1310";
+ reg = <1>;
+};
&sdio0 {
status = "okay";
diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index 6cab468..8612658 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -258,5 +258,40 @@
dmacap,xor;
};
};
+
+ compatible = "marvell,orion-mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72004 0x84>;
+ interrupts = <30>;
+ clocks = <&gate_clk 2>;
+ status = "disabled";
+
+ ethphy: ethernet-phy {
+ device-type = "ethernet-phy";
+ /* set phy address in board file */
+ };
+ };
+
+ compatible = "marvell,orion-eth";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72000 0x4000>;
+ clocks = <&gate_clk 2>;
+ marvell,tx-checksum-limit = <1600>;
+ status = "disabled";
+
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg = <0>;
+ interrupts = <29>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
Hi Sebastian

Its probably a good idea to set the local administration bit in this
MAC address. i.e. first byte is 02.

Andrew
Sebastian Hesselbarth
2013-05-22 09:43:15 UTC
Permalink
Post by Simon Baatz
Post by Sebastian Hesselbarth
This patch adds orion-eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to set its reg property on a per-board
basis.
---
...
Post by Simon Baatz
Post by Sebastian Hesselbarth
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg =<0>;
+ interrupts =<29>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
Hi Sebastian
Its probably a good idea to set the local administration bit in this
MAC address. i.e. first byte is 02.
Andrew,

we just need an invalid address here to trigger the default behavior of
the driver and load the MAC address from its register. As PPC binding
documentation also has all zero, I just took it.

Sebastian
tiejun.chen
2013-05-22 10:04:18 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Simon Baatz
Post by Sebastian Hesselbarth
This patch adds orion-eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to set its reg property on a per-board
basis.
---
...
Post by Simon Baatz
Post by Sebastian Hesselbarth
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg =<0>;
+ interrupts =<29>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
Hi Sebastian
Its probably a good idea to set the local administration bit in this
MAC address. i.e. first byte is 02.
Andrew,
we just need an invalid address here to trigger the default behavior of
the driver and load the MAC address from its register. As PPC binding
documentation also has all zero, I just took it.
The truth is in PPC case, often we set the real mac address with some variables
like 'eth[x]addr' in u-boot prompt, then u-boot will parse that value to fill
the dtb. At last the associated driver can get the actual mac address from the
dtb. And especially for those older u-boot version, even you have to reset the
'local-mac-address' property in dts directly with the real mac address before
generate the dtb since the older u-boot have no this ability to fill dtb again
before pass the kernel.

Tiejun
Sebastian Hesselbarth
2013-05-22 10:13:58 UTC
Permalink
Post by tiejun.chen
Post by Sebastian Hesselbarth
Post by Simon Baatz
Post by Sebastian Hesselbarth
This patch adds orion-eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to set its reg property on a per-board
basis.
---
...
Post by Simon Baatz
Post by Sebastian Hesselbarth
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg =<0>;
+ interrupts =<29>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
Hi Sebastian
Its probably a good idea to set the local administration bit in this
MAC address. i.e. first byte is 02.
Andrew,
we just need an invalid address here to trigger the default behavior of
the driver and load the MAC address from its register. As PPC binding
documentation also has all zero, I just took it.
The truth is in PPC case, often we set the real mac address with some
variables like 'eth[x]addr' in u-boot prompt, then u-boot will parse
that value to fill the dtb. At last the associated driver can get the
actual mac address from the dtb. And especially for those older u-boot
version, even you have to reset the 'local-mac-address' property in dts
directly with the real mac address before generate the dtb since the
older u-boot have no this ability to fill dtb again before pass the kernel.
Tiejun,

with Marvell SoCs it is no different, except that there is almost no dtb
support in their u-boot. The default behavior of the driver always was
to load the MAC address from its register if there is no valid overwrite
value. Using an invalid address (and all zero above is invalid) will
cause of_get_mac_address() to fail (which we allow), the corresponding
platform_data will never be written, and cause the default behavior.

We only need an invalid address passed initially on local-mac-address.
DT aware boot loader will overwrite but DT agnositic boot loader will
not. I can put any invalid MAC address in here, so I have chosen the
very first I can think of.

Sebastian
Jason Cooper
2013-05-22 13:10:10 UTC
Permalink
Post by Sebastian Hesselbarth
Post by tiejun.chen
Post by Sebastian Hesselbarth
Post by Simon Baatz
Post by Sebastian Hesselbarth
This patch adds orion-eth and mvmdio device tree nodes for DT enabled
Dove boards. As there is only one ethernet controller on Dove, a default
phy node is also added with a note to set its reg property on a per-board
basis.
---
...
Post by Simon Baatz
Post by Sebastian Hesselbarth
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg =<0>;
+ interrupts =<29>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
Hi Sebastian
Its probably a good idea to set the local administration bit in this
MAC address. i.e. first byte is 02.
Andrew,
we just need an invalid address here to trigger the default behavior of
the driver and load the MAC address from its register. As PPC binding
documentation also has all zero, I just took it.
The truth is in PPC case, often we set the real mac address with some
variables like 'eth[x]addr' in u-boot prompt, then u-boot will parse
that value to fill the dtb. At last the associated driver can get the
actual mac address from the dtb. And especially for those older u-boot
version, even you have to reset the 'local-mac-address' property in dts
directly with the real mac address before generate the dtb since the
older u-boot have no this ability to fill dtb again before pass the kernel.
Tiejun,
with Marvell SoCs it is no different, except that there is almost no dtb
support in their u-boot.
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.

thx,

Jason.
Jason Gunthorpe
2013-05-22 16:59:08 UTC
Permalink
Post by Jason Cooper
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.
Sorry, no, we don't use ATAGs here, our platforms start the kernel
with a correct DTB that has the correct mac address to use. My patch
was to have the driver accept it, and I think Sebastian has already
got that functionality...

Jason
Jason Cooper
2013-05-22 17:01:57 UTC
Permalink
Post by Jason Gunthorpe
Post by Jason Cooper
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.
Sorry, no, we don't use ATAGs here, our platforms start the kernel
with a correct DTB that has the correct mac address to use. My patch
was to have the driver accept it, and I think Sebastian has already
got that functionality...
Yes, you're right.

thx,

Jason.
Sebastian Hesselbarth
2013-05-22 17:32:51 UTC
Permalink
Post by Jason Gunthorpe
Post by Jason Cooper
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.
Sorry, no, we don't use ATAGs here, our platforms start the kernel
with a correct DTB that has the correct mac address to use. My patch
was to have the driver accept it, and I think Sebastian has already
got that functionality...
Not neccessary anyway, after talking Jason C in a Kirkwood-only
workaround I prepared a patch that reads mac address registers early
and stores it in the local-mac-address property.

Just tested on Dockstar with gated clocks and modular DT mv643xx_eth.

Will append to the DT mv643xx_eth patch set if a v5 will be required
or as single patch prior Jason C taking in the ARM part of it
otherwise.

Sebastian
Jason Cooper
2013-05-22 17:35:05 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Jason Gunthorpe
Post by Jason Cooper
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.
Sorry, no, we don't use ATAGs here, our platforms start the kernel
with a correct DTB that has the correct mac address to use. My patch
was to have the driver accept it, and I think Sebastian has already
got that functionality...
Not neccessary anyway, after talking Jason C in a Kirkwood-only
workaround I prepared a patch that reads mac address registers early
and stores it in the local-mac-address property.
Sweet!
Post by Sebastian Hesselbarth
Just tested on Dockstar with gated clocks and modular DT mv643xx_eth.
Will append to the DT mv643xx_eth patch set if a v5 will be required
or as single patch prior Jason C taking in the ARM part of it
otherwise.
Please post, in-reply-to v4 is fine.

thx,

Jason.
Sebastian Hesselbarth
2013-05-22 17:42:36 UTC
Permalink
Post by Jason Cooper
Post by Sebastian Hesselbarth
Post by Jason Gunthorpe
Post by Jason Cooper
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.
Sorry, no, we don't use ATAGs here, our platforms start the kernel
with a correct DTB that has the correct mac address to use. My patch
was to have the driver accept it, and I think Sebastian has already
got that functionality...
Not neccessary anyway, after talking Jason C in a Kirkwood-only
workaround I prepared a patch that reads mac address registers early
and stores it in the local-mac-address property.
Sweet!
Post by Sebastian Hesselbarth
Just tested on Dockstar with gated clocks and modular DT mv643xx_eth.
Will append to the DT mv643xx_eth patch set if a v5 will be required
or as single patch prior Jason C taking in the ARM part of it
otherwise.
Please post, in-reply-to v4 is fine.
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.

Will investigate and update patch set accordingly.

Sebastian
Jason Cooper
2013-05-22 17:48:15 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Jason Cooper
Post by Sebastian Hesselbarth
Post by Jason Gunthorpe
Post by Jason Cooper
iirc, our solution to this was to parse the ATAGs for the mac addr and
update the appended dtb. This way, module load and unload would work
without loosing the mac address. I believe Jason Gunthorpe has a patch
to atags_to_fdt() for this... This should allow us to get rid of the
clocks hack.
Sorry, no, we don't use ATAGs here, our platforms start the kernel
with a correct DTB that has the correct mac address to use. My patch
was to have the driver accept it, and I think Sebastian has already
got that functionality...
Not neccessary anyway, after talking Jason C in a Kirkwood-only
workaround I prepared a patch that reads mac address registers early
and stores it in the local-mac-address property.
Sweet!
Post by Sebastian Hesselbarth
Just tested on Dockstar with gated clocks and modular DT mv643xx_eth.
Will append to the DT mv643xx_eth patch set if a v5 will be required
or as single patch prior Jason C taking in the ARM part of it
otherwise.
Please post, in-reply-to v4 is fine.
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.
Will investigate and update patch set accordingly.
Cool, chances are, we should be able to take that patch in by itself for
this merge window...

thx,

Jason.
Sebastian Hesselbarth
2013-05-22 18:44:20 UTC
Permalink
Post by Jason Cooper
Post by Sebastian Hesselbarth
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.
Will investigate and update patch set accordingly.
Cool, chances are, we should be able to take that patch in by itself for
this merge window...
Which patch do you mean? The local-mac-address workaround will only be
available for DT mv643xx_eth because it uses the DT node to store the
MAC.

Anyway, I found the bit that caused the other issue. It is the
Clk125_Bypass_En bit in PORT_SERIAL_CONTROL1 register. What bothers me
about it is:
- Only Dove and Kirkwood have the bit, MV78x00 doesn't have it, Orion5x
doesn't have the register at all. With ppc mv64x60 I can only guess,
but think it is like in Orion5x.
- Reset value of that bit should be 0, but after gating clock on
Kirkwood it is set to 1 causing wrong port clock to be selected.
Also Thomas Petazzoni confirmed that it is set after reset so
either FS is wrong about it or BootROM messes with it.
- Kirkwood and Dove FS tell me that port link must be down when you
change the bit.

As I can't be sure about how mv643xx_eth will behave on other platforms
except Kirkwood and Dove when writing that register, I tend to force
that bit to zero in the driver but only for those two by #ifdefs.

Sebastian
Jason Cooper
2013-05-22 18:49:36 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Jason Cooper
Post by Sebastian Hesselbarth
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.
Will investigate and update patch set accordingly.
Cool, chances are, we should be able to take that patch in by itself for
this merge window...
Which patch do you mean? The local-mac-address workaround will only be
available for DT mv643xx_eth because it uses the DT node to store the
MAC.
I thought you were replacing the unconditional ethernet clock grabbing
with reading the mac from the registers and updating the dtb? In
mach-kirkwood/board-dt.c?

confused. :-/

Jason.
Sebastian Hesselbarth
2013-05-22 18:55:01 UTC
Permalink
Post by Jason Cooper
Post by Sebastian Hesselbarth
Post by Jason Cooper
Post by Sebastian Hesselbarth
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.
Will investigate and update patch set accordingly.
Cool, chances are, we should be able to take that patch in by itself for
this merge window...
Which patch do you mean? The local-mac-address workaround will only be
available for DT mv643xx_eth because it uses the DT node to store the
MAC.
I thought you were replacing the unconditional ethernet clock grabbing
with reading the mac from the registers and updating the dtb? In
mach-kirkwood/board-dt.c?
True. But there is no node for ethernet controllers in kirkwood.dtsi
yet. It will be there with mv643xx_eth DT patches applied and that is
when the corresponding replacement patch should also be taken in.

I was just confused about your referral to the merge window, because I
guess it is up to David Miller to decide when/whether to take
mv643xx_eth patches in.

Sebastian
Jason Cooper
2013-05-22 18:58:35 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Jason Cooper
Post by Sebastian Hesselbarth
Post by Jason Cooper
Post by Sebastian Hesselbarth
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.
Will investigate and update patch set accordingly.
Cool, chances are, we should be able to take that patch in by itself for
this merge window...
Which patch do you mean? The local-mac-address workaround will only be
available for DT mv643xx_eth because it uses the DT node to store the
MAC.
I thought you were replacing the unconditional ethernet clock grabbing
with reading the mac from the registers and updating the dtb? In
mach-kirkwood/board-dt.c?
True. But there is no node for ethernet controllers in kirkwood.dtsi
yet. It will be there with mv643xx_eth DT patches applied and that is
when the corresponding replacement patch should also be taken in.
I was just confused about your referral to the merge window, because I
guess it is up to David Miller to decide when/whether to take
mv643xx_eth patches in.
Ahh, no, that was me. I was contemplating adding the dt entries in this
merge window at one point and must've got my wires crossed. Sorry for
the confusion.

thx,

Jason.
Sebastian Hesselbarth
2013-05-22 19:52:40 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Jason Cooper
Post by Sebastian Hesselbarth
Just tested on Dockstar with gated clocks and modular DT mv643xx_eth.
Will append to the DT mv643xx_eth patch set if a v5 will be required
or as single patch prior Jason C taking in the ARM part of it
otherwise.
Please post, in-reply-to v4 is fine.
Hmm, maybe a little bit too early. While restoring the MAC address now
works, another bug arises which I guess is related with phy setup
and aneg.
Will investigate and update patch set accordingly.
Ok, have it working now by properly clearing CLK125_BYPASS_EN bit in
PORT_SERIAL_CTRL1 register for Kirkwood only. I have two more patches
ready that I will post as single patches in reply to v4.

If David gives his ACK for the patch set and names a branch to base it
on, I will send a v5 including all patches.

Sebastian
Jason Gunthorpe
2013-05-22 18:24:48 UTC
Permalink
Post by Sebastian Hesselbarth
Not neccessary anyway, after talking Jason C in a Kirkwood-only
workaround I prepared a patch that reads mac address registers early
and stores it in the local-mac-address property.
That sounds great, but, FWIW, our bootloaders don't set the MAC
address registers. Does the work around only trigger if the
local-mac-address property is 0?

Jason
Sebastian Hesselbarth
2013-05-22 18:51:26 UTC
Permalink
Post by Jason Gunthorpe
Post by Sebastian Hesselbarth
Not neccessary anyway, after talking Jason C in a Kirkwood-only
workaround I prepared a patch that reads mac address registers early
and stores it in the local-mac-address property.
That sounds great, but, FWIW, our bootloaders don't set the MAC
address registers. Does the work around only trigger if the
local-mac-address property is 0?
I already thought about bootloaders not setting the register, but I will
not start parsing 1001 places for a valid MAC only for those. Also
reading the MAC address registers is default behavior of mv643xx_eth if
no MAC address is passed through platform_data.

But you are right, there is plenty of sanity checks in the workaround to
ensure that local-mac-address is only overwritten by it when
- you are on DT
- there is no valid MAC address in that node (of_get_mac_address)
- there is a local-mac-address property with a length of 6 bytes

So this workaround only applies on DT booted kernels with no mac set in
DT.

Sebastian
Sebastian Hesselbarth
2013-05-21 16:41:40 UTC
Permalink
Make use of managed devm_ioremap and remove corresponding iounmap.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index ef3454c..e658ebd 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2470,7 +2470,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (msp == NULL)
return -ENOMEM;

- msp->base = ioremap(res->start, resource_size(res));
+ msp->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (msp->base == NULL)
return -ENOMEM;

@@ -2498,7 +2498,6 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
{
struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev);

- iounmap(msp->base);
if (!IS_ERR(msp->clk))
clk_disable_unprepare(msp->clk);
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:48 UTC
Permalink
With all boards converted to DT enabled mv643xx_eth we can now
remove the clock alias for gbe clocks. The workaround for ge0/ge1 clock
gates is not removed, as Kirkwood ethernet controllers loose MAC address
stored in internal registers on gated ge0/ge1 clocks.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Note: I confirm that the above workaround is still required, i.e. when
booting DT kernel with non-DT boot loader (no local-mac-address property)
MAC address registers looses its content on clock gating.

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/mach-kirkwood/board-dt.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index e9647b8..8db388a 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -66,12 +66,10 @@ static void __init kirkwood_legacy_clk_init(void)
*/
clkspec.args[0] = CGC_BIT_GE0;
clk = of_clk_get_from_provider(&clkspec);
- orion_clkdev_add(NULL, "mv643xx_eth_port.0", clk);
clk_prepare_enable(clk);

clkspec.args[0] = CGC_BIT_GE1;
clk = of_clk_get_from_provider(&clkspec);
- orion_clkdev_add(NULL, "mv643xx_eth_port.1", clk);
clk_prepare_enable(clk);
}
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:47 UTC
Permalink
With DT support for mv643xx_eth we do not need legacy platform_data
based setup for DT enabled boards anymore.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/mach-dove/board-dt.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/arch/arm/mach-dove/board-dt.c b/arch/arm/mach-dove/board-dt.c
index 0b14280..048e942 100644
--- a/arch/arm/mach-dove/board-dt.c
+++ b/arch/arm/mach-dove/board-dt.c
@@ -34,10 +34,6 @@ static void __init dove_legacy_clk_init(void)
clkspec.np = np;
clkspec.args_count = 1;

- clkspec.args[0] = CLOCK_GATING_BIT_GBE;
- orion_clkdev_add(NULL, "mv643xx_eth_port.0",
- of_clk_get_from_provider(&clkspec));
-
clkspec.args[0] = CLOCK_GATING_BIT_PCIE0;
orion_clkdev_add("0", "pcie",
of_clk_get_from_provider(&clkspec));
@@ -53,10 +49,6 @@ static void __init dove_of_clk_init(void)
dove_legacy_clk_init();
}

-static struct mv643xx_eth_platform_data dove_dt_ge00_data = {
- .phy_addr = MV643XX_ETH_PHY_ADDR_DEFAULT,
-};
-
static void __init dove_dt_init(void)
{
pr_info("Dove 88AP510 SoC\n");
@@ -70,7 +62,6 @@ static void __init dove_dt_init(void)
dove_of_clk_init();

/* Internal devices not ported to DT yet */
- dove_ge00_init(&dove_dt_ge00_data);
dove_pcie_init(1, 1);

of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:41 UTC
Permalink
This adds a struct device_node pointer for a phy passed by phandle
to mv643xx_eth node.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
include/linux/mv643xx_eth.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index 141d395..6e8215b 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -30,6 +30,7 @@ struct mv643xx_eth_shared_platform_data {
#define MV643XX_ETH_PHY_ADDR(x) (0x80 | (x))
#define MV643XX_ETH_PHY_NONE 0xff

+struct device_node;
struct mv643xx_eth_platform_data {
/*
* Pointer back to our parent instance, and our port number.
@@ -41,6 +42,7 @@ struct mv643xx_eth_platform_data {
* Whether a PHY is present, and if yes, at which address.
*/
int phy_addr;
+ struct device_node *phy_node;

/*
* Use this MAC address if it is valid, overriding the
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:45 UTC
Permalink
This patch adds mv643xx_eth and mvmdio device tree nodes for DT enabled
Kirkwood boards. Phy nodes are also added with reg property set on a
per-board basis.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Changelog:
v3->v4:
- convert to new device tree binding
- fix phy addr of kirkwood-ts219-6282.dts (Reported by Andrew Lunn)
- fix mvmdio interrupt (Reported by Simon Baatz)

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/boot/dts/kirkwood-cloudbox.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-dnskw.dtsi | 16 ++++++
arch/arm/boot/dts/kirkwood-dockstar.dts | 17 +++++++
arch/arm/boot/dts/kirkwood-dreamplug.dts | 28 +++++++++++
arch/arm/boot/dts/kirkwood-goflexnet.dts | 16 ++++++
.../arm/boot/dts/kirkwood-guruplug-server-plus.dts | 30 +++++++++++
arch/arm/boot/dts/kirkwood-ib62x0.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-iconnect.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts | 24 +++++++++
arch/arm/boot/dts/kirkwood-is2.dts | 2 +
arch/arm/boot/dts/kirkwood-km_kirkwood.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-lsxl.dtsi | 28 +++++++++++
arch/arm/boot/dts/kirkwood-mplcec4.dts | 27 ++++++++++
.../boot/dts/kirkwood-netgear_readynas_duo_v2.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-ns2-common.dtsi | 16 ++++++
arch/arm/boot/dts/kirkwood-ns2.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2lite.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2max.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2mini.dts | 2 +
arch/arm/boot/dts/kirkwood-openblocks_a6.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-topkick.dts | 16 ++++++
arch/arm/boot/dts/kirkwood-ts219-6281.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219-6282.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219.dtsi | 16 ++++++
arch/arm/boot/dts/kirkwood.dtsi | 52 ++++++++++++++++++++
25 files changed, 398 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-cloudbox.dts b/arch/arm/boot/dts/kirkwood-cloudbox.dts
index 5f21d4e..03e1b68 100644
--- a/arch/arm/boot/dts/kirkwood-cloudbox.dts
+++ b/arch/arm/boot/dts/kirkwood-cloudbox.dts
@@ -87,3 +87,19 @@
gpios = <&gpio0 17 0>;
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
index 6875ac0..7c8bc17 100644
--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -217,3 +217,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ reg = <8>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dockstar.dts b/arch/arm/boot/dts/kirkwood-dockstar.dts
index 0196cf6..b5aebbc 100644
--- a/arch/arm/boot/dts/kirkwood-dockstar.dts
+++ b/arch/arm/boot/dts/kirkwood-dockstar.dts
@@ -91,3 +91,20 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ compatible = "marvell,88e1116";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
index 289e51d..e0c93d4 100644
--- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -99,3 +99,31 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+
+ ethphy1: ethernet-***@1 {
+ device_type = "ethernet-phy";
+ reg = <1>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
+
+&eth1 {
+ status = "okay";
+ ethernet1-***@0 {
+ phy-handle = <&ethphy1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-goflexnet.dts b/arch/arm/boot/dts/kirkwood-goflexnet.dts
index c3573be..aba5849 100644
--- a/arch/arm/boot/dts/kirkwood-goflexnet.dts
+++ b/arch/arm/boot/dts/kirkwood-goflexnet.dts
@@ -170,3 +170,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts b/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts
index 44fd97d..210dfb9 100644
--- a/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts
+++ b/arch/arm/boot/dts/kirkwood-guruplug-server-plus.dts
@@ -96,3 +96,33 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ compatible = "marvell,88e1121";
+ reg = <0>;
+ };
+
+ ethphy1: ethernet-***@1 {
+ device_type = "ethernet-phy";
+ compatible = "marvell,88e1121";
+ reg = <1>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
+
+&eth1 {
+ status = "okay";
+ ethernet1-***@0 {
+ phy-handle = <&ethphy1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index 5335b1a..fff3e65 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -119,3 +119,19 @@


};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ reg = <8>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-iconnect.dts b/arch/arm/boot/dts/kirkwood-iconnect.dts
index 12ccf74..cfaf6bc 100644
--- a/arch/arm/boot/dts/kirkwood-iconnect.dts
+++ b/arch/arm/boot/dts/kirkwood-iconnect.dts
@@ -168,3 +168,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@11 {
+ device_type = "ethernet-phy";
+ reg = <11>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts b/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts
index 3694e94..315f095 100644
--- a/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts
+++ b/arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts
@@ -191,3 +191,27 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy1: ethernet-***@11 {
+ device_type = "ethernet-phy";
+ reg = <11>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ speed = <1000>;
+ duplex = <1>;
+ };
+};
+
+&eth1 {
+ status = "okay";
+ ethernet1-***@0 {
+ phy-handle = <&ethphy1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-is2.dts b/arch/arm/boot/dts/kirkwood-is2.dts
index 0bdce0a..2e5fe72 100644
--- a/arch/arm/boot/dts/kirkwood-is2.dts
+++ b/arch/arm/boot/dts/kirkwood-is2.dts
@@ -28,3 +28,5 @@
};
};
};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-km_kirkwood.dts b/arch/arm/boot/dts/kirkwood-km_kirkwood.dts
index 5bbd054..f9194b1 100644
--- a/arch/arm/boot/dts/kirkwood-km_kirkwood.dts
+++ b/arch/arm/boot/dts/kirkwood-km_kirkwood.dts
@@ -43,3 +43,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-lsxl.dtsi b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
index 37d45c4..dcc6470 100644
--- a/arch/arm/boot/dts/kirkwood-lsxl.dtsi
+++ b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
@@ -201,3 +201,31 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+
+ ethphy1: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ reg = <8>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
+
+&eth1 {
+ status = "okay";
+ ethernet1-***@0 {
+ phy-handle = <&ethphy1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-mplcec4.dts b/arch/arm/boot/dts/kirkwood-mplcec4.dts
index 7588241..ceac0de 100644
--- a/arch/arm/boot/dts/kirkwood-mplcec4.dts
+++ b/arch/arm/boot/dts/kirkwood-mplcec4.dts
@@ -182,3 +182,30 @@
};
};

+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@1 {
+ device_type = "ethernet-phy";
+ reg = <1>;
+ };
+
+ ethphy1: ethernet-***@2 {
+ device_type = "ethernet-phy";
+ reg = <2>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
+
+&eth1 {
+ status = "okay";
+ ethernet1-***@0 {
+ phy-handle = <&ethphy1>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts b/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts
index 1ca66ab..b66b2cd 100644
--- a/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts
+++ b/arch/arm/boot/dts/kirkwood-netgear_readynas_duo_v2.dts
@@ -178,3 +178,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ns2-common.dtsi b/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
index 6affd92..6a48bfd 100644
--- a/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
@@ -82,3 +82,19 @@
};

};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-phy {
+ device_type = "ethernet-phy";
+ /* overwrite reg property in board file */
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ns2.dts b/arch/arm/boot/dts/kirkwood-ns2.dts
index f2d36ecf..8ffd552 100644
--- a/arch/arm/boot/dts/kirkwood-ns2.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2.dts
@@ -28,3 +28,5 @@
};
};
};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ns2lite.dts b/arch/arm/boot/dts/kirkwood-ns2lite.dts
index b02eb4e..16332f8 100644
--- a/arch/arm/boot/dts/kirkwood-ns2lite.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2lite.dts
@@ -28,3 +28,5 @@
};
};
};
+
+&ethphy0 { reg = <0>; };
diff --git a/arch/arm/boot/dts/kirkwood-ns2max.dts b/arch/arm/boot/dts/kirkwood-ns2max.dts
index bcec4d6..68d767d 100644
--- a/arch/arm/boot/dts/kirkwood-ns2max.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2max.dts
@@ -47,3 +47,5 @@
};
};
};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ns2mini.dts b/arch/arm/boot/dts/kirkwood-ns2mini.dts
index adab1ab..5b1b17b 100644
--- a/arch/arm/boot/dts/kirkwood-ns2mini.dts
+++ b/arch/arm/boot/dts/kirkwood-ns2mini.dts
@@ -48,3 +48,5 @@
};
};
};
+
+&ethphy0 { reg = <0>; };
diff --git a/arch/arm/boot/dts/kirkwood-openblocks_a6.dts b/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
index d27f724..f8be3e3 100644
--- a/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
+++ b/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
@@ -210,3 +210,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-topkick.dts b/arch/arm/boot/dts/kirkwood-topkick.dts
index 66eb45b..34eacf2 100644
--- a/arch/arm/boot/dts/kirkwood-topkick.dts
+++ b/arch/arm/boot/dts/kirkwood-topkick.dts
@@ -201,3 +201,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-***@0 {
+ device_type = "ethernet-phy";
+ reg = <0>;
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6281.dts b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
index 8295c83..0bd67bf 100644
--- a/arch/arm/boot/dts/kirkwood-ts219-6281.dts
+++ b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
@@ -49,4 +49,6 @@
gpios = <&gpio0 16 1>;
};
};
-};
\ No newline at end of file
+};
+
+&ethphy0 { reg = <8>; };
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6282.dts b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
index df3f95d..a675278 100644
--- a/arch/arm/boot/dts/kirkwood-ts219-6282.dts
+++ b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
@@ -49,4 +49,6 @@
gpios = <&gpio1 5 1>;
};
};
-};
\ No newline at end of file
+};
+
+&ethphy0 { reg = <0>; };
diff --git a/arch/arm/boot/dts/kirkwood-ts219.dtsi b/arch/arm/boot/dts/kirkwood-ts219.dtsi
index 64ea27c..68fe091 100644
--- a/arch/arm/boot/dts/kirkwood-ts219.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ts219.dtsi
@@ -76,3 +76,19 @@
};
};
};
+
+&mdio {
+ status = "okay";
+
+ ethphy0: ethernet-phy {
+ device_type = "ethernet-phy";
+ /* overwrite reg property in board file */
+ };
+};
+
+&eth0 {
+ status = "okay";
+ ethernet0-***@0 {
+ phy-handle = <&ethphy0>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index fada7e6..7c2b690 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -202,5 +202,57 @@
clocks = <&gate_clk 4>;
status = "disabled";
};
+
+ mdio: mdio-***@72004 {
+ compatible = "marvell,orion-mdio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72004 0x84>;
+ interrupts = <46>;
+ clocks = <&gate_clk 0>;
+ status = "disabled";
+
+ /* add phy nodes in board file */
+ };
+
+ eth0: ethernet-***@72000 {
+ compatible = "marvell,orion-eth";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72000 0x4000>;
+ clocks = <&gate_clk 0>;
+ marvell,tx-checksum-limit = <1600>;
+ status = "disabled";
+
+ ethernet0-***@0 {
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg = <0>;
+ interrupts = <11>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
+ /* set phy-handle property in board file */
+ };
+ };
+
+ eth1: ethernet-***@76000 {
+ compatible = "marvell,orion-eth";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x76000 0x4000>;
+ clocks = <&gate_clk 19>;
+ marvell,tx-checksum-limit = <1600>;
+ status = "disabled";
+
+ ethernet1-***@1 {
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg = <1>;
+ interrupts = <15>;
+ /* overwrite MAC address in bootloader */
+ local-mac-address = [00 00 00 00 00 00];
+ /* set phy-handle property in board file */
+ };
+ };
};
};
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:38 UTC
Permalink
This patch set picks up work by Florian Fainelli bringing full DT
support to mv643xx_eth and Marvell SoCs using it.

The current v4 patch set drops 1:1 compatibiliy with PPC binding
for two reasons:
(a) PPC parses DT nodes in arch/ppc/sysdev and creates non-DT
platform_devices itself,
(b) property and node naming for new ethernet devices is slightly
different ("phy" vs "phy-handle", "marvell," prefix)

Anyway, the two bindings are functionally compatible and PPC bindings
can be converted if desireable. The patch set if fully bisectable and
care has been taken to (a) not reparse on PPC platforms, (b) allow to
use platform_device based registration even if on CONFIG_OF. Not tested
is double registration issues, i.e. if DT nodes are provided but legacy
registration it not yet removed. This double registration should lead
to either non-DT or DT registered device fail on already claimed
ressources.

Also this patch set picks up the opportunity to fix some repeatedly
reported issues with modular mvmdio/mv643xx_eth loading, unloading,
and reloading. It has been tested on SolidRun CuBox (Dove) and
Seagate Dockstar (Kirkwood) so far.

Patch 1 fixes an issue introduced with switch to separate mvmdio
driver, where detaching mv643xx_eth from a phy will not stop the
phy state machine and finally dereference the already removed network
device. Using phy_disconnect properly stops the phy state machine
before detaching from it. Perhaps, this patch should go back in
stable (most likely 3.9 only) if mvmdio separation patch went in
there.

Patch 2 makes use of managed devm_ioremap for the last remaining
non-managed resource.

Patches 3-4 prepare DT support for mv643xx_eth by adding a phy_node
pointer to platform_data and exploiting that phy_node when attaching
to a phy.

Patch 5 introduces DT parsing support for mv643xx_eth by adding a
match table to the shared driver and adding a platform_device for
each of its child nodes.

Patches 6-8 add corresponding device tree nodes to Marvell Dove,
Kirkwood, and Orion5x including all boards. Where known, also
the PHY compatible string has been set to what is reported in the
boards boot loader.

Patches 9, 10-11, and 12 finally remove all legacy platform_device
based registration from Dove, Kirkwood, and Orion5x DT setup. For
Kirkwood also now obsolete board specific setup is removed from
common DT board setup, Kconfig, Makefile, and kirkwood_defconfig.

For the patches above I suggest to take Patches 1-5 through David
Miller's branch, and Patches 6-12 through Jason Cooper's when they
have appeared on mainline linux. The patch set has been based on
todays net-next, if I shall rebase them on any other branch please
name it.

Sebastian Hesselbarth (12):
net: mv643xx_eth: use phy_disconnect instead of phy_detach
net: mv643xx_eth: use managed devm_ioremap for port registers
net: mv643xx_eth: add phy_node to platform_data struct
net: mv643xx_eth: use of_phy_connect if phy_node present
net: mv643xx_eth: add DT parsing support
ARM: dove: add gigabit ethernet and mvmdio device tree nodes
ARM: kirkwood: add gigabit ethernet and mvmdio device tree nodes
ARM: orion5x: add gigabit ethernet and mvmdio device tree nodes
ARM: dove: remove legacy mv643xx_eth setup
ARM: kirkwood: remove legacy clk alias for mv643xx_eth
ARM: kirkwood: remove redundant DT board files
ARM: orion5x: remove legacy mv643xx_eth board setup

.../devicetree/bindings/net/marvell-orion-net.txt | 83 +++++++++
arch/arm/boot/dts/dove-cubox.dts | 7 +
arch/arm/boot/dts/dove.dtsi | 35 ++++
arch/arm/boot/dts/kirkwood-cloudbox.dts | 16 ++
arch/arm/boot/dts/kirkwood-dnskw.dtsi | 16 ++
arch/arm/boot/dts/kirkwood-dockstar.dts | 17 ++
arch/arm/boot/dts/kirkwood-dreamplug.dts | 28 +++
arch/arm/boot/dts/kirkwood-goflexnet.dts | 16 ++
.../arm/boot/dts/kirkwood-guruplug-server-plus.dts | 30 ++++
arch/arm/boot/dts/kirkwood-ib62x0.dts | 16 ++
arch/arm/boot/dts/kirkwood-iconnect.dts | 16 ++
arch/arm/boot/dts/kirkwood-iomega_ix2_200.dts | 24 +++
arch/arm/boot/dts/kirkwood-is2.dts | 2 +
arch/arm/boot/dts/kirkwood-km_kirkwood.dts | 16 ++
arch/arm/boot/dts/kirkwood-lsxl.dtsi | 28 +++
arch/arm/boot/dts/kirkwood-mplcec4.dts | 27 +++
.../boot/dts/kirkwood-netgear_readynas_duo_v2.dts | 16 ++
arch/arm/boot/dts/kirkwood-ns2-common.dtsi | 16 ++
arch/arm/boot/dts/kirkwood-ns2.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2lite.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2max.dts | 2 +
arch/arm/boot/dts/kirkwood-ns2mini.dts | 2 +
arch/arm/boot/dts/kirkwood-openblocks_a6.dts | 16 ++
arch/arm/boot/dts/kirkwood-topkick.dts | 16 ++
arch/arm/boot/dts/kirkwood-ts219-6281.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219-6282.dts | 4 +-
arch/arm/boot/dts/kirkwood-ts219.dtsi | 16 ++
arch/arm/boot/dts/kirkwood.dtsi | 52 ++++++
.../dts/orion5x-lacie-ethernet-disk-mini-v2.dts | 17 ++
arch/arm/boot/dts/orion5x.dtsi | 29 ++++
arch/arm/configs/kirkwood_defconfig | 16 --
arch/arm/mach-dove/board-dt.c | 9 -
arch/arm/mach-kirkwood/Kconfig | 117 -------------
arch/arm/mach-kirkwood/Makefile | 16 --
arch/arm/mach-kirkwood/board-dnskw.c | 7 -
arch/arm/mach-kirkwood/board-dockstar.c | 32 ----
arch/arm/mach-kirkwood/board-dreamplug.c | 35 ----
arch/arm/mach-kirkwood/board-dt.c | 40 -----
arch/arm/mach-kirkwood/board-goflexnet.c | 34 ----
arch/arm/mach-kirkwood/board-guruplug.c | 33 ----
arch/arm/mach-kirkwood/board-ib62x0.c | 29 ----
arch/arm/mach-kirkwood/board-iconnect.c | 10 --
arch/arm/mach-kirkwood/board-iomega_ix2_200.c | 34 ----
arch/arm/mach-kirkwood/board-km_kirkwood.c | 44 -----
arch/arm/mach-kirkwood/board-lsxl.c | 16 --
arch/arm/mach-kirkwood/board-mplcec4.c | 14 --
arch/arm/mach-kirkwood/board-ns2.c | 35 ----
arch/arm/mach-kirkwood/board-openblocks_a6.c | 26 ---
arch/arm/mach-kirkwood/board-readynas.c | 6 -
arch/arm/mach-kirkwood/board-ts219.c | 13 --
arch/arm/mach-kirkwood/board-usi_topkick.c | 29 ----
arch/arm/mach-orion5x/edmini_v2-setup.c | 10 --
drivers/net/ethernet/marvell/mv643xx_eth.c | 182 ++++++++++++++++++--
include/linux/mv643xx_eth.h | 2 +
54 files changed, 739 insertions(+), 621 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/marvell-orion-net.txt
delete mode 100644 arch/arm/mach-kirkwood/board-dockstar.c
delete mode 100644 arch/arm/mach-kirkwood/board-dreamplug.c
delete mode 100644 arch/arm/mach-kirkwood/board-goflexnet.c
delete mode 100644 arch/arm/mach-kirkwood/board-guruplug.c
delete mode 100644 arch/arm/mach-kirkwood/board-ib62x0.c
delete mode 100644 arch/arm/mach-kirkwood/board-iomega_ix2_200.c
delete mode 100644 arch/arm/mach-kirkwood/board-km_kirkwood.c
delete mode 100644 arch/arm/mach-kirkwood/board-ns2.c
delete mode 100644 arch/arm/mach-kirkwood/board-openblocks_a6.c
delete mode 100644 arch/arm/mach-kirkwood/board-usi_topkick.c
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:43 UTC
Permalink
This adds device tree parsing support for the shared driver of mv643xx_eth.
As the bindings are slightly different from current PPC bindings new binding
documentation is also added. Following PPC-style device setup, the shared
driver now also adds port platform_devices and sets up port platform_data.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Note: Although different, device tree bindings are compatible with PPC
bindings. As I do not have access to any PPC platform using mv643xx_eth,
I leave conversion ("phy" vs "phy-handle") and compatible string name
up to PPC guys.

Due to hang reports for modular built mvmdio and mv643xx_eth, I have
tested module loading/unloading/reloading on CuBox (Dove) and Dockstar
(Kirkwood) without any issues for the whole patch set.

Changelog:
v3->v4:
- separation of independent patches (phy, of_mdio, devm)
- stand-alone device tree binding compatible to existing mv64x60 binding
- device node match for shared driver only
- device node registration for port drivers
- properly return -EPROBE_DEFER on missing of phy (Reported by Simon Baatz)

v2->v3:
- rebase on top of mv643xx_eth clean-ups
- do not reparse existing platform_data
- use managed devm_kzalloc for parsed platform_data
- use of_property_read_u32 where applicable
- add phy_node to platform_data
- use of_connect_phy if DT phy node was found

v1->v2:
- properly ifdef of_platform_bus_probe with CONFIG_OF
- handle of_platform_bus_probe errors and cleanup accordingly
- use of_property_read_u32 where applicable
- parse "duplex" and "speed" property in PHY-less configuration

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
.../devicetree/bindings/net/marvell-orion-net.txt | 83 +++++++++++
drivers/net/ethernet/marvell/mv643xx_eth.c | 152 +++++++++++++++++++-
2 files changed, 231 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/marvell-orion-net.txt

diff --git a/Documentation/devicetree/bindings/net/marvell-orion-net.txt b/Documentation/devicetree/bindings/net/marvell-orion-net.txt
new file mode 100644
index 0000000..23ffd57
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/marvell-orion-net.txt
@@ -0,0 +1,83 @@
+Marvell Orion/Discovery ethernet controller
+=============================================
+
+The Marvell Discovery ethernet controller can be found on Marvell Orion SoCs
+(Kirkwood, Dove, Orion5x, and Discovery Innovation) and as part of Marvell
+Discovery system controller chips (mv64[345]60).
+
+The Discovery ethernet controller is described with two levels of nodes. The
+first level describes the ethernet controller itself and the second level
+describes up to 3 ethernet port nodes within that controller. The reason for
+the multiple levels is that the port registers are interleaved within a single
+set of controller registers. Each port node describes port-specific properties.
+
+Note: The above separation is only true for Discovery system controllers.
+For Orion SoCs we stick to the separation, although there each controller has
+only one port associated. Multiple ports are implemented as multiple single-port
+controllers.
+
+* Ethernet controller node
+
+Required controller properties:
+ - #address-cells: shall be 1.
+ - #size-cells: shall be 0.
+ - compatible: shall be "marvell,orion-eth".
+ - reg: address and length of the controller registers.
+
+Optional controller properties:
+ - clocks: phandle reference to the controller clock.
+ - marvell,tx-checksum-limit: max tx packet size for hardware checksum.
+
+* Ethernet port node
+
+Required port properties:
+ - device_type: shall be "network".
+ - compatible: shall be "marvell,orion-eth-port".
+ - reg: port number relative to ethernet controller, shall be 0, 1, or 2.
+ - interrupts: port interrupt.
+ - local-mac-address: 6 bytes MAC address.
+
+Optional port properties:
+ - marvell,tx-queue-size: size of the transmit ring buffer.
+ - marvell,tx-sram-addr: address of transmit descriptor buffer located in SRAM.
+ - marvell,tx-sram-size: size of transmit descriptor buffer located in SRAM.
+ - marvell,rx-queue-size: size of the receive ring buffer.
+ - marvell,rx-sram-addr: address of receive descriptor buffer located in SRAM.
+ - marvell,rx-sram-size: size of receive descriptor buffer located in SRAM.
+
+and
+
+ - phy-handle: phandle reference to ethernet PHY.
+
+or
+
+ - speed: port speed if no PHY connected.
+ - duplex: port mode if no PHY connected.
+
+* Node example:
+
+mdio-bus {
+ ...
+ ethphy: ethernet-***@8 {
+ device_type = "ethernet-phy";
+ ...
+ };
+};
+
+eth: ethernet-***@72000 {
+ compatible = "marvell,orion-eth";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x72000 0x2000>;
+ clocks = <&gate_clk 2>;
+ marvell,tx-checksum-limit = <1600>;
+
+ ***@0 {
+ device_type = "network";
+ compatible = "marvell,orion-eth-port";
+ reg = <0>;
+ interrupts = <29>;
+ phy-handle = <&ethphy>;
+ local-mac-address = [00 00 00 00 00 00];
+ };
+};
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 0f5c3c2..f2c229c 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -60,6 +60,9 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
#include <linux/of_mdio.h>

static char mv643xx_eth_driver_name[] = "mv643xx_eth";
@@ -2451,13 +2454,147 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
}
}

+#if defined(CONFIG_OF)
+static const struct of_device_id mv643xx_eth_shared_ids[] = {
+ { .compatible = "marvell,orion-eth", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_ids);
+#endif
+
+#if defined(CONFIG_OF) && !defined(CONFIG_MV64X60)
+#define mv643xx_eth_property(_np, _name, _v) \
+ do { \
+ u32 tmp; \
+ if (!of_property_read_u32(_np, "marvell," _name, &tmp)) \
+ _v = tmp; \
+ } while (0)
+
+static struct platform_device *port_platdev[3];
+
+static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
+ struct device_node *pnp)
+{
+ struct platform_device *ppdev;
+ struct mv643xx_eth_platform_data ppd;
+ struct resource res;
+ const char *mac_addr;
+ int ret;
+
+ memset(&ppd, 0, sizeof(ppd));
+ ppd.shared = pdev;
+
+ memset(&res, 0, sizeof(res));
+ if (!of_irq_to_resource(pnp, 0, &res)) {
+ dev_err(&pdev->dev, "missing interrupt on %s\n", pnp->name);
+ return -EINVAL;
+ }
+
+ if (of_property_read_u32(pnp, "reg", &ppd.port_number)) {
+ dev_err(&pdev->dev, "missing reg property on %s\n", pnp->name);
+ return -EINVAL;
+ }
+
+ if (ppd.port_number >= 3) {
+ dev_err(&pdev->dev, "invalid reg property on %s\n", pnp->name);
+ return -EINVAL;
+ }
+
+ mac_addr = of_get_mac_address(pnp);
+ if (mac_addr)
+ memcpy(ppd.mac_addr, mac_addr, 6);
+
+ mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size);
+ mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr);
+ mv643xx_eth_property(pnp, "tx-sram-size", ppd.tx_sram_size);
+ mv643xx_eth_property(pnp, "rx-queue-size", ppd.rx_queue_size);
+ mv643xx_eth_property(pnp, "rx-sram-addr", ppd.rx_sram_addr);
+ mv643xx_eth_property(pnp, "rx-sram-size", ppd.rx_sram_size);
+
+ ppd.phy_node = of_parse_phandle(pnp, "phy-handle", 0);
+ if (!ppd.phy_node) {
+ ppd.phy_addr = MV643XX_ETH_PHY_NONE;
+ of_property_read_u32(pnp, "speed", &ppd.speed);
+ of_property_read_u32(pnp, "duplex", &ppd.duplex);
+ }
+
+ ppdev = platform_device_alloc(MV643XX_ETH_NAME, ppd.port_number);
+ if (!ppdev)
+ return -ENOMEM;
+ ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
+ ret = platform_device_add_resources(ppdev, &res, 1);
+ if (ret)
+ goto port_err;
+
+ ret = platform_device_add_data(ppdev, &ppd, sizeof(ppd));
+ if (ret)
+ goto port_err;
+
+ ret = platform_device_add(ppdev);
+ if (ret)
+ goto port_err;
+
+ port_platdev[ppd.port_number] = ppdev;
+
+ return 0;
+
+port_err:
+ platform_device_put(ppdev);
+ return ret;
+}
+
+static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
+{
+ struct mv643xx_eth_shared_platform_data *pd;
+ struct device_node *pnp, *np = pdev->dev.of_node;
+ int ret;
+
+ /* bail out if not registered from DT */
+ if (!np)
+ return 0;
+
+ pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return -ENOMEM;
+ pdev->dev.platform_data = pd;
+
+ mv643xx_eth_property(np, "tx-checksum-limit", pd->tx_csum_limit);
+
+ for_each_available_child_of_node(np, pnp) {
+ ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
+static void mv643xx_eth_shared_of_remove(void)
+{
+ int n;
+
+ for (n = 0; n < 3; n++) {
+ platform_device_del(port_platdev[n]);
+ port_platdev[n] = NULL;
+ }
+}
+#else
+static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
+{
+ return 0
+}
+
+#define mv643xx_eth_shared_of_remove()
+#endif
+
static int mv643xx_eth_shared_probe(struct platform_device *pdev)
{
static int mv643xx_eth_version_printed;
- struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
+ struct mv643xx_eth_shared_platform_data *pd;
struct mv643xx_eth_shared_private *msp;
const struct mbus_dram_target_info *dram;
struct resource *res;
+ int ret;

if (!mv643xx_eth_version_printed++)
pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
@@ -2470,6 +2607,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL);
if (msp == NULL)
return -ENOMEM;
+ platform_set_drvdata(pdev, msp);

msp->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (msp->base == NULL)
@@ -2486,12 +2624,15 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram);

+ ret = mv643xx_eth_shared_of_probe(pdev);
+ if (ret)
+ return ret;
+ pd = pdev->dev.platform_data;
+
msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
pd->tx_csum_limit : 9 * 1024;
infer_hw_params(msp);

- platform_set_drvdata(pdev, msp);
-
return 0;
}

@@ -2499,9 +2640,9 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
{
struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev);

+ mv643xx_eth_shared_of_remove();
if (!IS_ERR(msp->clk))
clk_disable_unprepare(msp->clk);
-
return 0;
}

@@ -2511,6 +2652,7 @@ static struct platform_driver mv643xx_eth_shared_driver = {
.driver = {
.name = MV643XX_ETH_SHARED_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(mv643xx_eth_shared_ids),
},
};

@@ -2710,6 +2852,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
if (!IS_ERR(mp->clk)) {
clk_prepare_enable(mp->clk);
mp->t_clk = clk_get_rate(mp->clk);
+ } else if (!IS_ERR(mp->shared->clk)) {
+ mp->t_clk = clk_get_rate(mp->shared->clk);
}

set_params(mp, pd);
--
1.7.10.4
Sebastian Hesselbarth
2013-05-21 16:41:42 UTC
Permalink
This connects to a phy node passed to the port device instead of probing
the phy by phy_addr.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index e658ebd..0f5c3c2 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -60,6 +60,7 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/clk.h>
+#include <linux/of_mdio.h>

static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4";
@@ -2715,17 +2716,27 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
netif_set_real_num_tx_queues(dev, mp->txq_count);
netif_set_real_num_rx_queues(dev, mp->rxq_count);

- if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
+ err = 0;
+ if (pd->phy_node) {
+ mp->phy = of_phy_connect(mp->dev, pd->phy_node,
+ mv643xx_eth_adjust_link, 0,
+ PHY_INTERFACE_MODE_GMII);
+ if (!mp->phy)
+ err = -ENODEV;
+ } else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
mp->phy = phy_scan(mp, pd->phy_addr);

- if (IS_ERR(mp->phy)) {
+ if (IS_ERR(mp->phy))
err = PTR_ERR(mp->phy);
- if (err == -ENODEV)
- err = -EPROBE_DEFER;
- goto out;
- }
- phy_init(mp, pd->speed, pd->duplex);
+ else
+ phy_init(mp, pd->speed, pd->duplex);
}
+ if (err == -ENODEV) {
+ err = -EPROBE_DEFER;
+ goto out;
+ }
+ if (err)
+ goto out;

SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops);
--
1.7.10.4
Andrew Lunn
2013-05-22 16:16:21 UTC
Permalink
Post by Sebastian Hesselbarth
This patch set picks up work by Florian Fainelli bringing full DT
support to mv643xx_eth and Marvell SoCs using it.
Hi Sebastian

I tested on my QNAP and topkick. Works great.

Tested-by: Andrew Lunn <***@lunn.ch>

Andrew
Sebastian Hesselbarth
2013-05-22 20:04:01 UTC
Permalink
Kirkwood ethernet controllers suffer from loosing MAC register content
on gated clocks. In the past this was prevented by not gating the ethernet
controller clocks. With DT support for mv643xx_eth and corresponding
nodes available, a different approach is more reasonable.

This patch replaces the former clock gating workaround by parsing the
ethernet controller nodes for *invalid* MAC addresses and overwrites
the local-mac-address property with MAC register contents early. The
clock can now properly gated in modular mv643xx_eth and DT agnostic
boot loader scenarios because mv643xx_eth will find the stored MAC
in the corresponding MAC address property.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
arch/arm/mach-kirkwood/board-dt.c | 67 +++++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index a86b41c..0aad9f7 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -13,6 +13,8 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/clk-provider.h>
#include <linux/clk/mvebu.h>
@@ -31,6 +33,56 @@ static struct of_device_id kirkwood_dt_match_table[] __initdata = {
};

/*
+ * Kirkwood ethernet controllers suffer from loosing the MAC address
+ * register content on gated clocks. Rather than always ungate the
+ * clocks, we get the MAC address early and put it into DT for those
+ * boot loaders that don't provide a valid MAC address property.
+ */
+#define ETH_MAC_ADDR_L(n) (0x400 + ((n) * 0x400) + 0x14)
+#define ETH_MAC_ADDR_H(n) (0x400 + ((n) * 0x400) + 0x18)
+
+static void __init kirkwood_dt_eth_quirk(void)
+{
+ struct device_node *np;
+
+ for_each_compatible_node(np, NULL, "marvell,orion-eth") {
+ struct device_node *pnp;
+ void __iomem *base;
+
+ if (!of_device_is_available(np))
+ continue;
+
+ base = of_iomap(np, 0);
+ if (!base)
+ continue;
+
+ for_each_available_child_of_node(np, pnp) {
+ const void *mac_addr;
+ struct property *p;
+ u32 n, reg[2];
+
+ mac_addr = of_get_mac_address(pnp);
+ if (mac_addr)
+ continue;
+
+ p = of_find_property(pnp, "local-mac-address", NULL);
+ if (!p || p->length != 6)
+ continue;
+
+ if (of_property_read_u32(pnp, "reg", &n))
+ continue;
+
+ reg[0] = cpu_to_be32(readl(base + ETH_MAC_ADDR_H(n)));
+ reg[1] = cpu_to_be32(readl(base +
+ ETH_MAC_ADDR_L(n)) << 16);
+ memcpy((void *)p->value, reg, 6);
+ }
+
+ iounmap(base);
+ }
+}
+
+/*
* There are still devices that doesn't know about DT yet. Get clock
* gates here and add a clock lookup alias, so that old platform
* devices still work.
@@ -42,7 +94,6 @@ static void __init kirkwood_legacy_clk_init(void)
struct device_node *np = of_find_compatible_node(
NULL, NULL, "marvell,kirkwood-gating-clock");
struct of_phandle_args clkspec;
- struct clk *clk;

clkspec.np = np;
clkspec.args_count = 1;
@@ -58,19 +109,6 @@ static void __init kirkwood_legacy_clk_init(void)
clkspec.args[0] = CGC_BIT_SDIO;
orion_clkdev_add(NULL, "mvsdio",
of_clk_get_from_provider(&clkspec));
-
- /*
- * The ethernet interfaces forget the MAC address assigned by
- * u-boot if the clocks are turned off. Until proper DT support
- * is available we always enable them for now.
- */
- clkspec.args[0] = CGC_BIT_GE0;
- clk = of_clk_get_from_provider(&clkspec);
- clk_prepare_enable(clk);
-
- clkspec.args[0] = CGC_BIT_GE1;
- clk = of_clk_get_from_provider(&clkspec);
- clk_prepare_enable(clk);
}

static void __init kirkwood_of_clk_init(void)
@@ -97,6 +135,7 @@ static void __init kirkwood_dt_init(void)

/* Setup root of clk tree */
kirkwood_of_clk_init();
+ kirkwood_dt_eth_quirk();

kirkwood_cpuidle_init();
--
1.7.10.4
Sebastian Hesselbarth
2013-05-22 20:04:02 UTC
Permalink
Ethernet controllers found on Kirkwood SoCs not only suffer from loosing
MAC address register contents on clock gating but also some important
registers are reset to values that would break ethernet. This patch
clears the CLK125_BYPASS_EN bit for DT enabled Kirkwood only by using
of_machine_is_compatible() instead of #ifdefs. Non-DT Kirkwood is not
affected as it installs a clock gating workaround because of the MAC
address issue above. Other Orion SoCs do not suffer from register reset,
do not have the bit in question, or do not have the register at all.
Moreover, system controllers on PPC using this driver should also be
protected from clearing that bit.

Signed-off-by: Sebastian Hesselbarth <***@gmail.com>
---
Note: In contrast to the reset value of 0 for CLK125_BYPASS_EN bit as
stated in Kirkwood datasheet, we confirmed that reset value is 1 instead.
Either datasheet is wrong about it, there is some post-boot self-check or
BootROM flips that bit.

Cc: David Miller <***@davemloft.net>
Cc: Lennert Buytenhek <***@wantstofly.org>
Cc: Jason Cooper <***@lakedaemon.net>
Cc: Andrew Lunn <***@lunn.ch>
Cc: Benjamin Herrenschmidt <***@kernel.crashing.org>
Cc: ***@vger.kernel.org
Cc: linux-arm-***@lists.infradead.org
Cc: linuxppc-***@lists.ozlabs.org
Cc: linux-***@vger.kernel.org
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index f2c229c..d9ad8c7 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -119,6 +119,8 @@ static char mv643xx_eth_driver_version[] = "1.4";
#define LINK_UP 0x00000002
#define TXQ_COMMAND 0x0048
#define TXQ_FIX_PRIO_CONF 0x004c
+#define PORT_SERIAL_CONTROL1 0x004c
+#define CLK125_BYPASS_EN 0x00000010
#define TX_BW_RATE 0x0050
#define TX_BW_MTU 0x0058
#define TX_BW_BURST 0x005c
@@ -2843,6 +2845,14 @@ static int mv643xx_eth_probe(struct platform_device *pdev)

mp->dev = dev;

+ /* Kirkwood resets some registers on gated clocks. Especially
+ * CLK125_BYPASS_EN must be cleared but is not available on
+ * all other SoCs/System Controllers using this driver.
+ */
+ if (of_machine_is_compatible("marvell,kirkwood"))
+ wrlp(mp, PORT_SERIAL_CONTROL1,
+ rdlp(mp, PORT_SERIAL_CONTROL1) & ~CLK125_BYPASS_EN);
+
/*
* Start with a default rate, and if there is a clock, allow
* it to override the default.
--
1.7.10.4
Jason Gunthorpe
2013-05-22 20:16:07 UTC
Permalink
Post by Sebastian Hesselbarth
Ethernet controllers found on Kirkwood SoCs not only suffer from loosing
MAC address register contents on clock gating but also some important
registers are reset to values that would break ethernet. This patch
FWIW, we found that the bootloader has to write to PSC1, the driver
doesn't work with the power on/reset value of the register. So I think
it is safe to assume that all kirkwood bootloaders alter the value.

Our systems write the value 0x00638488 to PSC1.

I looked at patching mv643xx_eth, but ran into the same complexity you
did, it isn't clear what variants of this IP block have the
register/etc.
Post by Sebastian Hesselbarth
+ /* Kirkwood resets some registers on gated clocks. Especially
+ * CLK125_BYPASS_EN must be cleared but is not available on
+ * all other SoCs/System Controllers using this driver.
+ */
+ if (of_machine_is_compatible("marvell,kirkwood"))
+ wrlp(mp, PORT_SERIAL_CONTROL1,
+ rdlp(mp, PORT_SERIAL_CONTROL1) & ~CLK125_BYPASS_EN);
of_machine_is_compatible seems heavy handed, I would expect this to be
based on the compatible string of the ethernet node itself, not the
machine??

Jason
Sebastian Hesselbarth
2013-05-22 21:02:05 UTC
Permalink
Post by Jason Gunthorpe
Post by Sebastian Hesselbarth
Ethernet controllers found on Kirkwood SoCs not only suffer from loosing
MAC address register contents on clock gating but also some important
registers are reset to values that would break ethernet. This patch
FWIW, we found that the bootloader has to write to PSC1, the driver
doesn't work with the power on/reset value of the register. So I think
it is safe to assume that all kirkwood bootloaders alter the value.
It is safe to assume the bootloader alters it, but that modification is
lost when clocks get gated. I assume on clock ungate, the controller is
reset. Saying this, I will double check Dove's reset value but looks
like reset mess has been fixed in that later SoC.
Post by Jason Gunthorpe
Our systems write the value 0x00638488 to PSC1.
I looked at patching mv643xx_eth, but ran into the same complexity you
did, it isn't clear what variants of this IP block have the
register/etc.
For Orion SoCs it is quite clear to me, with Gregory Clement and Thomas
Petazzoni we could also confirm if it does any harm there if we
unconditionally clear it. But for PPC system controllers I have no
idea...
Post by Jason Gunthorpe
Post by Sebastian Hesselbarth
+ /* Kirkwood resets some registers on gated clocks. Especially
+ * CLK125_BYPASS_EN must be cleared but is not available on
+ * all other SoCs/System Controllers using this driver.
+ */
+ if (of_machine_is_compatible("marvell,kirkwood"))
+ wrlp(mp, PORT_SERIAL_CONTROL1,
+ rdlp(mp, PORT_SERIAL_CONTROL1)& ~CLK125_BYPASS_EN);
of_machine_is_compatible seems heavy handed, I would expect this to be
based on the compatible string of the ethernet node itself, not the
machine??
I have no strong opinion about checking the machine compatible or have
an extra compatible string for Kirkwood ethernet. Both would work fine
and are checked once upon probe anyway.

Sebastian
Jason Cooper
2013-05-23 16:01:11 UTC
Permalink
Sebastian,
Post by Jason Gunthorpe
Post by Sebastian Hesselbarth
Ethernet controllers found on Kirkwood SoCs not only suffer from loosing
MAC address register contents on clock gating but also some important
registers are reset to values that would break ethernet. This patch
FWIW, we found that the bootloader has to write to PSC1, the driver
doesn't work with the power on/reset value of the register. So I think
it is safe to assume that all kirkwood bootloaders alter the value.
Our systems write the value 0x00638488 to PSC1.
I looked at patching mv643xx_eth, but ran into the same complexity you
did, it isn't clear what variants of this IP block have the
register/etc.
Post by Sebastian Hesselbarth
+ /* Kirkwood resets some registers on gated clocks. Especially
+ * CLK125_BYPASS_EN must be cleared but is not available on
+ * all other SoCs/System Controllers using this driver.
+ */
+ if (of_machine_is_compatible("marvell,kirkwood"))
+ wrlp(mp, PORT_SERIAL_CONTROL1,
+ rdlp(mp, PORT_SERIAL_CONTROL1) & ~CLK125_BYPASS_EN);
of_machine_is_compatible seems heavy handed, I would expect this to be
based on the compatible string of the ethernet node itself, not the
machine??
Is there a model number variation between IP that needs this and IP that
doesn't? If not, I'm fine with of_machine_is_compatible().

thx,

Jason.
Jason Gunthorpe
2013-05-23 17:11:12 UTC
Permalink
Post by Jason Cooper
Post by Jason Gunthorpe
Post by Sebastian Hesselbarth
+ /* Kirkwood resets some registers on gated clocks. Especially
+ * CLK125_BYPASS_EN must be cleared but is not available on
+ * all other SoCs/System Controllers using this driver.
+ */
+ if (of_machine_is_compatible("marvell,kirkwood"))
+ wrlp(mp, PORT_SERIAL_CONTROL1,
+ rdlp(mp, PORT_SERIAL_CONTROL1) & ~CLK125_BYPASS_EN);
of_machine_is_compatible seems heavy handed, I would expect this to be
based on the compatible string of the ethernet node itself, not the
machine??
Is there a model number variation between IP that needs this and IP that
doesn't? If not, I'm fine with of_machine_is_compatible().
Well the name 'mv643xx' is a family of system controller SOC's
from ages ago, it seems reasonble to continue the trend and label the
IP variations with the SOC name:

compatible = "marvell,kirwood,ethernet", "marvell,mv643xx_eth"

Jason
Jason Cooper
2013-05-23 17:23:39 UTC
Permalink
Post by Jason Gunthorpe
Post by Jason Cooper
Post by Jason Gunthorpe
Post by Sebastian Hesselbarth
+ /* Kirkwood resets some registers on gated clocks. Especially
+ * CLK125_BYPASS_EN must be cleared but is not available on
+ * all other SoCs/System Controllers using this driver.
+ */
+ if (of_machine_is_compatible("marvell,kirkwood"))
+ wrlp(mp, PORT_SERIAL_CONTROL1,
+ rdlp(mp, PORT_SERIAL_CONTROL1) & ~CLK125_BYPASS_EN);
of_machine_is_compatible seems heavy handed, I would expect this to be
based on the compatible string of the ethernet node itself, not the
machine??
Is there a model number variation between IP that needs this and IP that
doesn't? If not, I'm fine with of_machine_is_compatible().
Well the name 'mv643xx' is a family of system controller SOC's
from ages ago, it seems reasonble to continue the trend and label the
compatible = "marvell,kirwood,ethernet", "marvell,mv643xx_eth"
Shouldn't it rather be

compatible = "marvell,kirkwood-eth", "marvell,orion-eth";

I'm inclined to go with of_machine_is_compatible() since the only
concrete difference we know is that the tweak is needed on kirkwood and
nowhere else.

If we had an errata, or a datasheet saying specifically flavor X needs
this and none other does, then we could trigger on the ethernet node
compatible string or a boolean in the node. But we don't have that...

thx,

Jason.
Jason Gunthorpe
2013-05-23 17:53:57 UTC
Permalink
Post by Jason Cooper
Shouldn't it rather be
compatible = "marvell,kirkwood-eth", "marvell,orion-eth";
Not sure about orion-eth?
Post by Jason Cooper
I'm inclined to go with of_machine_is_compatible() since the only
concrete difference we know is that the tweak is needed on kirkwood and
nowhere else.
But there is a larger problem here then just this one bit.

The PSC1 register must be set properly for the board layout, and today
we rely on the bootloader to set it. In fact, even with Sebastian's
change the ethernet port won't work without bootloader
intervention. The PortReset bit should also be cleared by the driver
(and it is only present on some variants of this IP block,
apparently).

We know that some Marvell SOC's wack the ethernet registers when they
clock gate, and the flip of Clk125Bypass is another symptom of this
general problem.

So, long term, the PSC1 must be fully set by the driver, based on DT
information describing the board (eg RGMII/MII/1000Base-X [SFP] Phy
type), and the layout of this register seems to vary on a SOC by SOC
basis.

Thus, I think it is appropriate to call this variant of the eth IP
'marvell,kirkwood-eth' which indicates that the register block follows
the kirkwood manual and the PSC1 register specifically has the
kirkwood layout.

The question is what other Marvell SOCs have the same PSC1 layout as
kirkwood?

Jason
Jason Cooper
2013-05-23 18:40:28 UTC
Permalink
Post by Jason Gunthorpe
Post by Jason Cooper
Shouldn't it rather be
compatible = "marvell,kirkwood-eth", "marvell,orion-eth";
Not sure about orion-eth?
Post by Jason Cooper
I'm inclined to go with of_machine_is_compatible() since the only
concrete difference we know is that the tweak is needed on kirkwood and
nowhere else.
But there is a larger problem here then just this one bit.
The PSC1 register must be set properly for the board layout, and today
we rely on the bootloader to set it. In fact, even with Sebastian's
change the ethernet port won't work without bootloader
intervention. The PortReset bit should also be cleared by the driver
(and it is only present on some variants of this IP block,
apparently).
We know that some Marvell SOC's wack the ethernet registers when they
clock gate, and the flip of Clk125Bypass is another symptom of this
general problem.
So, long term, the PSC1 must be fully set by the driver, based on DT
information describing the board (eg RGMII/MII/1000Base-X [SFP] Phy
type), and the layout of this register seems to vary on a SOC by SOC
basis.
Thus, I think it is appropriate to call this variant of the eth IP
'marvell,kirkwood-eth' which indicates that the register block follows
the kirkwood manual and the PSC1 register specifically has the
kirkwood layout.
Ok, so mv643xx_eth would match both "marvell,orion-eth" and
"marvell,kirkwood-eth", then write to PSC1 iff it sees a node matching
"marvell,kirkwood-eth". I'm not too keen on that, however, the matching
of the machine doesn't look to good, either.

Perhaps a better answer is to add a boolean, "marvell,kirkwood_psc1" and
check for that?

Or, marvell,psc1_reset = <0xWWXXYYZZ>;
Post by Jason Gunthorpe
The question is what other Marvell SOCs have the same PSC1 layout as
kirkwood?
I think marvell,psc1_reset = <>; gives us the most flexibility in
accurately describing the hardware.

thx,

Jason.
Jason Gunthorpe
2013-05-23 19:01:40 UTC
Permalink
Post by Jason Cooper
Post by Jason Gunthorpe
But there is a larger problem here then just this one bit.
The PSC1 register must be set properly for the board layout, and today
we rely on the bootloader to set it. In fact, even with Sebastian's
change the ethernet port won't work without bootloader
intervention. The PortReset bit should also be cleared by the driver
(and it is only present on some variants of this IP block,
apparently).
We know that some Marvell SOC's wack the ethernet registers when they
clock gate, and the flip of Clk125Bypass is another symptom of this
general problem.
So, long term, the PSC1 must be fully set by the driver, based on DT
information describing the board (eg RGMII/MII/1000Base-X [SFP] Phy
type), and the layout of this register seems to vary on a SOC by SOC
basis.
Thus, I think it is appropriate to call this variant of the eth IP
'marvell,kirkwood-eth' which indicates that the register block follows
the kirkwood manual and the PSC1 register specifically has the
kirkwood layout.
Ok, so mv643xx_eth would match both "marvell,orion-eth" and
"marvell,kirkwood-eth", then write to PSC1 iff it sees a node matching
"marvell,kirkwood-eth". I'm not too keen on that, however, the matching
of the machine doesn't look to good, either.
Why are you not keen on this? It seems like normal device driver
practice, that is what the data field of of_device_id is typically
used for..

There are more compatible strings than just kirkwood and orion in this
driver, the whole TX_BW_CONTROL_OLD_LAYOUT/TX_BW_CONTROL_NEW_LAYOUT
buisness (affecting PPC/MIPS) should also someday be captured with
compatible strings rather than auto-detection too..
Post by Jason Cooper
Post by Jason Gunthorpe
The question is what other Marvell SOCs have the same PSC1 layout as
kirkwood?
I think marvell,psc1_reset = <>; gives us the most flexibility in
accurately describing the hardware.
Agree, providing psc1_reset value is a good idea to setup the phy
modes. If all 'orion' SOCs have the PSC1 value then we don't need the
kirkwood differentiators, especially if things like the reset bit are
in the same place.

The same trick Sebastian used to capture the mac address could be used
to capture the PSC1 value from the bootloader.

Basically, I think any IP variants that have idential register layouts
can share a compatible string, otherwise different layouts need
different compatible strings, so the general format:

compatible = "marvell,SOCNAME-eth", "marvell,<something>-eth";

Seems very sane to me. At least this way if we discover more changes
then the driver can match on the SOCNAME compatible string to find
them.

<someting> = orion for TX_BW_CONTROL_NEW_LAYOUT variants also seems
reasonable..

No idea what to call TX_BW_CONTROL_OLD_LAYOUT variants, or the PPC
variants, not important right now it seems.

(BTW, I wonder if the driver should ideally toggle PSC1 reset at some
point????)

Jason
Jason Cooper
2013-05-24 16:46:36 UTC
Permalink
Post by Jason Gunthorpe
Post by Jason Cooper
Post by Jason Gunthorpe
But there is a larger problem here then just this one bit.
The PSC1 register must be set properly for the board layout, and today
we rely on the bootloader to set it. In fact, even with Sebastian's
change the ethernet port won't work without bootloader
intervention. The PortReset bit should also be cleared by the driver
(and it is only present on some variants of this IP block,
apparently).
We know that some Marvell SOC's wack the ethernet registers when they
clock gate, and the flip of Clk125Bypass is another symptom of this
general problem.
So, long term, the PSC1 must be fully set by the driver, based on DT
information describing the board (eg RGMII/MII/1000Base-X [SFP] Phy
type), and the layout of this register seems to vary on a SOC by SOC
basis.
Thus, I think it is appropriate to call this variant of the eth IP
'marvell,kirkwood-eth' which indicates that the register block follows
the kirkwood manual and the PSC1 register specifically has the
kirkwood layout.
Ok, so mv643xx_eth would match both "marvell,orion-eth" and
"marvell,kirkwood-eth", then write to PSC1 iff it sees a node matching
"marvell,kirkwood-eth". I'm not too keen on that, however, the matching
of the machine doesn't look to good, either.
Why are you not keen on this? It seems like normal device driver
practice, that is what the data field of of_device_id is typically
used for..
I'm not keen on it because we don't have a document saying "All kirkwood
SoCs need PSC1 set to X after reset." We know it, but have we tested
the 6282?

That being said, if "marvell,kirkwood-eth" is the best we can do for
now, I'm all for it. I would just like to be reasonably certain that
the binding we are creating doesn't lock us into a difficult decision
later.
Post by Jason Gunthorpe
There are more compatible strings than just kirkwood and orion in this
driver, the whole TX_BW_CONTROL_OLD_LAYOUT/TX_BW_CONTROL_NEW_LAYOUT
buisness (affecting PPC/MIPS) should also someday be captured with
compatible strings rather than auto-detection too..
Agreed.
Post by Jason Gunthorpe
Post by Jason Cooper
Post by Jason Gunthorpe
The question is what other Marvell SOCs have the same PSC1 layout as
kirkwood?
I think marvell,psc1_reset = <>; gives us the most flexibility in
accurately describing the hardware.
Agree, providing psc1_reset value is a good idea to setup the phy
modes. If all 'orion' SOCs have the PSC1 value then we don't need the
kirkwood differentiators, especially if things like the reset bit are
in the same place.
The same trick Sebastian used to capture the mac address could be used
to capture the PSC1 value from the bootloader.
Basically, I think any IP variants that have idential register layouts
can share a compatible string, otherwise different layouts need
compatible = "marvell,SOCNAME-eth", "marvell,<something>-eth";
Seems very sane to me. At least this way if we discover more changes
then the driver can match on the SOCNAME compatible string to find
them.
After glancing a LinusW's email, I'm thinking this isn't the correct
path. I'll write more in my response to him.

thx,

Jason.
Andrew Lunn
2013-05-24 16:53:15 UTC
Permalink
Post by Jason Cooper
Post by Jason Gunthorpe
Why are you not keen on this? It seems like normal device driver
practice, that is what the data field of of_device_id is typically
used for..
I'm not keen on it because we don't have a document saying "All kirkwood
SoCs need PSC1 set to X after reset." We know it, but have we tested
the 6282?
6282 looses its MAC address, that much i know. I've no idea about
PSC1, but if its MAC address behaviour is the same as 6281, is expect
PSC1 is the same.

Andrew
Jason Cooper
2013-05-24 17:03:35 UTC
Permalink
Post by Andrew Lunn
Post by Jason Cooper
Post by Jason Gunthorpe
Why are you not keen on this? It seems like normal device driver
practice, that is what the data field of of_device_id is typically
used for..
I'm not keen on it because we don't have a document saying "All kirkwood
SoCs need PSC1 set to X after reset." We know it, but have we tested
the 6282?
6282 looses its MAC address, that much i know. I've no idea about
PSC1, but if its MAC address behaviour is the same as 6281, is expect
PSC1 is the same.
Do you have a board set up for testing you could try Sebastian's
forthcoming series on (with "marvell,kirkwood-eth")?

thx,

Jason.
Jason Gunthorpe
2013-05-24 17:33:06 UTC
Permalink
Post by Jason Cooper
Post by Jason Gunthorpe
Why are you not keen on this? It seems like normal device driver
practice, that is what the data field of of_device_id is typically
used for..
I'm not keen on it because we don't have a document saying "All kirkwood
SoCs need PSC1 set to X after reset." We know it, but have we tested
the 6282?
I disagree. The manul is very clear how PSC1 must be set for proper
operation. Clk125BypassEn bit is used only for loopback testing, it
should never set for driver operation. Similarly PortReset must be
cleared for driver operation.

It is always safe for the driver to clear these bits, if it knows they
are available. In fact, I would argue the driver should always clear
these bits so that the bootloader isn't relied on to do it. It doesn't
matter if the SOC errantly sets the bit or not, it can *always* be
safely cleared.

Further, I compared my 88F6282/88F6283 manual against the public
88F6180/88F619x/88F6281 spec and confirmed that the PSC1 layout is the
same.

So all of these SOC's can share a driver compatible string.

AFAICT the only reason the driver doesn't touch PSC1 today is because
the PSC1 was introduced in a later IP revision and its presence isn't
auto-detectable.

The last bit of the puzzle to get bootloader independence on kirkwood
is to encode the phy interface type (GMII/RGMII/BASE-X) in the DT so
the entire PSC1 can be set by the driver..

Jason
Sebastian Hesselbarth
2013-05-23 22:40:26 UTC
Permalink
Post by Jason Cooper
Post by Jason Gunthorpe
Post by Jason Cooper
Shouldn't it rather be
compatible = "marvell,kirkwood-eth", "marvell,orion-eth";
Not sure about orion-eth?
Jason, Jason,

sorry I didn't came back to this conversation earlier. I already
reworked the patch to rely on
of_device_is_compatible(.."marvell,kirkwood-eth"..). This is a
kirkwood only thing as other Orions cannot do clock gating or
retain critcal register content (Dove). I will stick with orion-eth
for all other and maybe introduce new compatible strings (and new
fixes) as soon as issues surface.
Post by Jason Cooper
Post by Jason Gunthorpe
Post by Jason Cooper
I'm inclined to go with of_machine_is_compatible() since the only
concrete difference we know is that the tweak is needed on kirkwood and
nowhere else.
But there is a larger problem here then just this one bit.
The PSC1 register must be set properly for the board layout, and today
we rely on the bootloader to set it. In fact, even with Sebastian's
change the ethernet port won't work without bootloader
intervention. The PortReset bit should also be cleared by the driver
(and it is only present on some variants of this IP block,
apparently).
Actually, fixing modular scenarios is only for the sake of multiarch
someday. I don't see the point in running current kernel without eth
compiled in _on a NAS SoC_ ;)

On Dockstar which I tested, clearing CLK125_BYPASS_EN to make it work
after clock gating, it might be a coincidence that bootloader's PSC1
setup matches reset value here - so please test the patch on other
Kirkwood boards also.

But, as long as no other issue arise, I will not start to modifiy
mv643xx_eth out of the blue. I has been working for ages and breaking
PPC is not my intention. There are other things David Miller already
requested to get fixed and honestly I even thought about a fresh start
for it. Maybe I'll come back to it when barebox gets it's driver
someday.
Post by Jason Cooper
Post by Jason Gunthorpe
We know that some Marvell SOC's wack the ethernet registers when they
clock gate, and the flip of Clk125Bypass is another symptom of this
general problem.
Which SoCs except Kirkwood? I cannot reproduce any of this behavior on
Dove - and from what I can see from the FS of Orion5x or MV78x00 there
are no clock gating registers.
Post by Jason Cooper
Post by Jason Gunthorpe
So, long term, the PSC1 must be fully set by the driver, based on DT
information describing the board (eg RGMII/MII/1000Base-X [SFP] Phy
type), and the layout of this register seems to vary on a SOC by SOC
basis.
Agree, but I tend to not go at it now. mv643xx_eth has never set up that
registers and actually it never connects anything else than GMII phy (or
no phy at all). The latter is easy but the for the other, I like to
give up that brain-dead multi-device driver and stick with one device
for both shared and up to three ports. From what I can see from e.g.
ixgbe or any other multi-port eth drivers they all attach the network
device to a single (pci) device.
Post by Jason Cooper
Post by Jason Gunthorpe
Thus, I think it is appropriate to call this variant of the eth IP
'marvell,kirkwood-eth' which indicates that the register block follows
the kirkwood manual and the PSC1 register specifically has the
kirkwood layout.
Ok, so mv643xx_eth would match both "marvell,orion-eth" and
"marvell,kirkwood-eth", then write to PSC1 iff it sees a node matching
"marvell,kirkwood-eth". I'm not too keen on that, however, the matching
of the machine doesn't look to good, either.
I didn't choose "marvell,mv643xx-eth" for two reasons
(a) The DT layout is slightly different with phy-handle instead of phy
and marvell prefixed properties. Choosing a compatible string that
matches any PPC compatible string will cause driver racing with sysdev
code to set up platform_data.

(b) I chose to name the controller "orion-eth" and the port
"orion-eth-port" .. PPC has "mv64360-eth" for the port and some
"mv64360-eth-block" or "-group" for the controller. IMHO not intuitive,
but it just a name anyway.
Post by Jason Cooper
Perhaps a better answer is to add a boolean, "marvell,kirkwood_psc1" and
check for that?
Or, marvell,psc1_reset =<0xWWXXYYZZ>;
For the _long_ run: Exploit either already present phy properties for
MII and friends or introduce new marvell prefixed .. but not misuse DT
for register values here. Each SoC should setup mv643xx_eth properly,
but that should be based on a clean approach _and_ enough people willing
to test that.

I just have a Dockstar and Topkick which is running 24/7. I didn't even
check if only 6281 suffers from it or also 6282 or maybe only some
revisions of 6281. This patch is a fix, nothing more nothing
less. If you have Kirkwoods around, please test if it suffers from
loosing the MAC address and if it works after insmod with the fix
installed.
Post by Jason Cooper
Post by Jason Gunthorpe
The question is what other Marvell SOCs have the same PSC1 layout as
kirkwood?
I think marvell,psc1_reset =<>; gives us the most flexibility in
accurately describing the hardware.
IMHO using that is just another workaround for a broken driver. We
could hack the whole register setup in DT as it would still accurately
describe HW. Don't get me wrong, but I don't like it.

Haven't checked how happy Linus Walleij is about pinctrl drivers with
reg values hacked in lately.

Sebastian
Linus Walleij
2013-05-24 11:03:25 UTC
Permalink
On Fri, May 24, 2013 at 12:40 AM, Sebastian Hesselbarth
Post by Sebastian Hesselbarth
Post by Jason Cooper
I think marvell,psc1_reset =<>; gives us the most flexibility in
accurately describing the hardware.
IMHO using that is just another workaround for a broken driver. We
could hack the whole register setup in DT as it would still accurately
describe HW. Don't get me wrong, but I don't like it.
Haven't checked how happy Linus Walleij is about pinctrl drivers with
reg values hacked in lately.
One of the things I've been ranting about lately is that Linux
subsystem maintainers have become de-facto device tree
standard commite chairs. :-(

So to the actual question:

In general I think we need to draw a line and define what we
mean with "describing the hardware" in a device tree.

We have some consensus:
- <reg> properties to describe regsiter BASE offset in physical
memory and size.
- Resources like IRQ, DMA channel, regulator, GPIO pin control
handles, are passed using <&ampersand> notation.

And so it goes on.

When it comes to defining different registers and their individual
bits and the meaning of these and/or default values, I personally
think that is making things harder for developers rather than
simplifying things. I know that pinctrl-single is anyway doing this
and I was talked into accepting it under circumstances where
developers are being passed opaque machine-generated
data that would otherwise be translated into unreadable header
files littering the kernel.

For a coder it is definately better if the *driver* know these
details, but whether that is possible seems to depend on things
like hardware development process.

IMO: if you want to go down that road, what you really want is not
ever more expressible device trees, but real open firmware,
or ACPI or UEFI that can interpret and run bytecode as some
"bios" for you. With DT coming from OF maybe this is a natural
progression of things, but one has to realize when we reach the
point where what we really want is a bios. Then your time is
likely better spent with Tianocore or something than with the
kernel.

Yours,
Linus Walleij
Jason Cooper
2013-05-24 17:01:25 UTC
Permalink
Post by Linus Walleij
On Fri, May 24, 2013 at 12:40 AM, Sebastian Hesselbarth
Post by Sebastian Hesselbarth
Post by Jason Cooper
I think marvell,psc1_reset =<>; gives us the most flexibility in
accurately describing the hardware.
IMHO using that is just another workaround for a broken driver. We
could hack the whole register setup in DT as it would still accurately
describe HW. Don't get me wrong, but I don't like it.
Haven't checked how happy Linus Walleij is about pinctrl drivers with
reg values hacked in lately.
One of the things I've been ranting about lately is that Linux
subsystem maintainers have become de-facto device tree
standard commite chairs. :-(
This is the first I've heard this rant. :(

To that end, I agree with you. My frustration boiled down to trying to
predict the future, which is futile. :-P

For our scenario, once we can confirm our least popular kirkwood
variant, the 6282, behaves the same as we've seen so far, then
"marvell,kirkwood-eth" is fine by me.
Post by Linus Walleij
In general I think we need to draw a line and define what we
mean with "describing the hardware" in a device tree.
- <reg> properties to describe regsiter BASE offset in physical
memory and size.
- Resources like IRQ, DMA channel, regulator, GPIO pin control
handles, are passed using <&ampersand> notation.
And so it goes on.
When it comes to defining different registers and their individual
bits and the meaning of these and/or default values, I personally
think that is making things harder for developers rather than
simplifying things. I know that pinctrl-single is anyway doing this
and I was talked into accepting it under circumstances where
developers are being passed opaque machine-generated
data that would otherwise be translated into unreadable header
files littering the kernel.
For a coder it is definately better if the *driver* know these
details, but whether that is possible seems to depend on things
like hardware development process.
Agree.
Post by Linus Walleij
IMO: if you want to go down that road, what you really want is not
ever more expressible device trees, but real open firmware,
or ACPI or UEFI that can interpret and run bytecode as some
"bios" for you. With DT coming from OF maybe this is a natural
progression of things, but one has to realize when we reach the
point where what we really want is a bios. Then your time is
likely better spent with Tianocore or something than with the
kernel.
shudder. I like embedded systems because the *don't* have a bios.

thx,

Jason.
Russell King - ARM Linux
2013-05-24 17:13:00 UTC
Permalink
Post by Jason Cooper
Post by Linus Walleij
IMO: if you want to go down that road, what you really want is not
ever more expressible device trees, but real open firmware,
or ACPI or UEFI that can interpret and run bytecode as some
"bios" for you. With DT coming from OF maybe this is a natural
progression of things, but one has to realize when we reach the
point where what we really want is a bios. Then your time is
likely better spent with Tianocore or something than with the
kernel.
shudder. I like embedded systems because the *don't* have a bios.
Then you're into scenarios like I have with my laptop, where - those
of you who check the nightly build results will have noticed - one
of my serial ports doesn't always exist. That's because the ACPI data
in the BIOS is *wrong*. It reports that it has been enabled when it
hasn't, and the disassembled byte code is at fault here.

The fix? God knows. As far as I'm concerned as a user, or even as an
OS developer, it's unfixable without getting the ACPI data structures
changed, and that's not something I can do.

Do you really want that on ARM? Given the fiasco with the location of
the registers, are you sure you want to place more trust in that
direction? Does it give you a warm fuzzy feeling to know that you
might have to work out some way to patch vendor supplied bytecode?
Sebastian Hesselbarth
2013-05-24 17:25:11 UTC
Permalink
Post by Russell King - ARM Linux
Do you really want that on ARM? Given the fiasco with the location of
the registers, are you sure you want to place more trust in that
direction? Does it give you a warm fuzzy feeling to know that you
might have to work out some way to patch vendor supplied bytecode?
Don't get me wrong. I want mv643xx_eth DT or even platform_data to
evolve to a fully self configured driver not depending on proper u-boot
setup at all.

But I don't want to go that road now and I wonder if it might be safer
for us (and PPC guys) if we start mv643xx_eth over from scratch one day.

For this patch set, I want a basic DT binding that works. Patching the
driver to play with kirkwood loosing the MAC and other important
registers is not my main concern here. If clearing that one bit doesn't
help for all kirkwood boards, I'd rather leave the non-gating
workaround.

mv643xx_eth not knowing DT for ARM is stalling last important bits for
Orion SoCs. I want this to go in first as with David another maintainer
is involved.

Sebastian
Jason Cooper
2013-05-24 16:53:38 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Jason Gunthorpe
Post by Jason Cooper
Shouldn't it rather be
compatible = "marvell,kirkwood-eth", "marvell,orion-eth";
Not sure about orion-eth?
Sorry, yep, one or the other.
Post by Sebastian Hesselbarth
Jason, Jason,
For a second, I read this as "tsk tsk tsk..." ;-)
Post by Sebastian Hesselbarth
sorry I didn't came back to this conversation earlier. I already
reworked the patch to rely on
of_device_is_compatible(.."marvell,kirkwood-eth"..). This is a
kirkwood only thing as other Orions cannot do clock gating or
retain critcal register content (Dove). I will stick with orion-eth
for all other and maybe introduce new compatible strings (and new
fixes) as soon as issues surface.
Okay, as I mentioned to Jason, I would like to test 6282 before we
settle on this path. Other than that, I'm fine with it.
Post by Sebastian Hesselbarth
Post by Jason Gunthorpe
Post by Jason Cooper
I'm inclined to go with of_machine_is_compatible() since the only
concrete difference we know is that the tweak is needed on kirkwood and
nowhere else.
But there is a larger problem here then just this one bit.
The PSC1 register must be set properly for the board layout, and today
we rely on the bootloader to set it. In fact, even with Sebastian's
change the ethernet port won't work without bootloader
intervention. The PortReset bit should also be cleared by the driver
(and it is only present on some variants of this IP block,
apparently).
Actually, fixing modular scenarios is only for the sake of multiarch
someday. I don't see the point in running current kernel without eth
compiled in _on a NAS SoC_ ;)
Good point, but if the eth can be gated to save power, we shouldn't
limit the user's ability just because the SoC is primarily in NAS's.

thx,

Jason.
David Miller
2013-05-26 04:04:41 UTC
Permalink
From: Sebastian Hesselbarth <***@gmail.com>
Date: Wed, 22 May 2013 22:04:01 +0200
Post by Sebastian Hesselbarth
+ memcpy((void *)p->value, reg, 6);
This cast is completely unnecessary, non-void to void pointer casts
are automatic.

If it is necessary, because p->value is const, then you are trying
to change something behind the OF layer's back and need to use
the appropriate interface to change the property contents.
Sebastian Hesselbarth
2013-05-26 20:06:58 UTC
Permalink
Post by David Miller
Date: Wed, 22 May 2013 22:04:01 +0200
Post by Sebastian Hesselbarth
+ memcpy((void *)p->value, reg, 6);
This cast is completely unnecessary, non-void to void pointer casts
are automatic.
If it is necessary, because p->value is const, then you are trying
to change something behind the OF layer's back and need to use
the appropriate interface to change the property contents.
David,

good you mention it. I added Grant on Cc and will give a short
sum-up why I casted the const from property->value away here.

Maybe I overlooked the API for modifying the DT property but as
far as I've seen - there is no API for modifying it. And yes,
you are right, it is kind of an abuse of DT here.

As Kirkwoods loose their MAC address on clock gating, I was looking
for a place to store it early. (a) DT property "local-mac-address"
looked as a good place as it will allow the driver to find it without
any extra code. Of course, I am doing severaly sanity checks if it is
safe to overwrite it, i.e. no other MAC set, property is there, long
enough.

If Grant also NACKs modifying the DT we basically have two more options
left for Kirkwood: (b) have MAC stored early in two global arrays in
board init and reference that from mv643xx_eth or (c) leave the clock
ungated unconditionally on all Kirkwoods.

I can live with all three, just name it and I prepare a final patch set.

Sebastian
David Miller
2013-05-27 09:23:39 UTC
Permalink
From: Sebastian Hesselbarth <***@gmail.com>
Date: Sun, 26 May 2013 22:06:58 +0200
Post by Sebastian Hesselbarth
good you mention it. I added Grant on Cc and will give a short
sum-up why I casted the const from property->value away here.
Maybe I overlooked the API for modifying the DT property but as
far as I've seen - there is no API for modifying it. And yes,
you are right, it is kind of an abuse of DT here.
Sparc has an of_set_property(), it needs to become generic.
Benjamin Herrenschmidt
2013-05-27 09:39:25 UTC
Permalink
Post by David Miller
Sparc has an of_set_property(), it needs to become generic.
There is an of_update_property(), we could change the name though, yours
is nicer :-)

Cheers,
Ben.
Sebastian Hesselbarth
2013-05-27 10:24:07 UTC
Permalink
Post by Benjamin Herrenschmidt
Post by David Miller
Sparc has an of_set_property(), it needs to become generic.
There is an of_update_property(), we could change the name though, yours
is nicer :-)
Ben, David,

I had a quick look at sparc's of_set_property. Nothing special except it
depends on OF_DYNAMIC at some place. Using of_update_property instead
should be the correct function to use. Thanks for the hint, I'll update
the patches accordingly and send v5 hopefully by today.

Sebastian
Benjamin Herrenschmidt
2013-05-27 11:50:04 UTC
Permalink
Post by Sebastian Hesselbarth
Post by Benjamin Herrenschmidt
There is an of_update_property(), we could change the name though,
yours
Post by Benjamin Herrenschmidt
is nicer :-)
Ben, David,
I had a quick look at sparc's of_set_property. Nothing special except it
depends on OF_DYNAMIC at some place. Using of_update_property instead
should be the correct function to use. Thanks for the hint, I'll update
the patches accordingly and send v5 hopefully by today.
The only thing is that of_update_property() is a bit awkward to use,
requiring the caller to provide an allocated struct property with
associated allocated content. It also leaks the old property which
is annoying but we haven't sorted out how to deal with allocation
of properties and property content yet.

It would be handy to be able to just do something like

of_set_property(node, name, ptr, len);

However, that wouldn't help much with the allocation/leak problem,
though at least it would be easier to use. It could also *try* to re-use
the current allocation if the new content is of smaller or equal size.

Cheers,
Ben.

Benjamin Herrenschmidt
2013-05-27 09:38:31 UTC
Permalink
Post by Sebastian Hesselbarth
good you mention it. I added Grant on Cc and will give a short
sum-up why I casted the const from property->value away here.
Maybe I overlooked the API for modifying the DT property but as
far as I've seen - there is no API for modifying it. And yes,
you are right, it is kind of an abuse of DT here.
of_update_property(). That also makes sure that any notifiers
is called and proc/device-tree is updated in the case where the property
is new.
Post by Sebastian Hesselbarth
As Kirkwoods loose their MAC address on clock gating, I was looking
for a place to store it early. (a) DT property "local-mac-address"
looked as a good place as it will allow the driver to find it without
any extra code. Of course, I am doing severaly sanity checks if it is
safe to overwrite it, i.e. no other MAC set, property is there, long
enough.
If Grant also NACKs modifying the DT we basically have two more options
left for Kirkwood: (b) have MAC stored early in two global arrays in
board init and reference that from mv643xx_eth or (c) leave the clock
ungated unconditionally on all Kirkwoods.
I can live with all three, just name it and I prepare a final patch set.
No, putting it in the DT makes sense, just use the right accessor.

Cheers,
Ben.
Post by Sebastian Hesselbarth
Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Continue reading on narkive:
Loading...