mvebu: backport mainline patches from kernel 3.12
[openwrt/staging/chunkeey.git] / target / linux / mvebu / patches-3.10 / 0082-net-mvneta-add-support-for-fixed-links.patch
1 From 350a4e8e9d517d2d7c48bc915da5b1e30163add3 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Mon, 15 Jul 2013 17:34:10 +0200
4 Subject: [PATCH 082/203] net: mvneta: add support for fixed links
5
6 Following the introduction of of_phy_register_fixed_link(), this patch
7 introduces fixed link support in the mvneta driver, for Marvell Armada
8 370/XP SOCs.
9
10 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
11 ---
12 .../bindings/net/marvell-armada-370-neta.txt | 24 +++++++++++++++++++---
13 drivers/net/ethernet/marvell/mvneta.c | 18 +++++++++++-----
14 2 files changed, 34 insertions(+), 8 deletions(-)
15
16 --- a/Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt
17 +++ b/Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt
18 @@ -4,13 +4,21 @@ Required properties:
19 - compatible: should be "marvell,armada-370-neta".
20 - reg: address and length of the register set for the device.
21 - interrupts: interrupt for the device
22 -- phy: A phandle to a phy node defining the PHY address (as the reg
23 - property, a single integer).
24 - phy-mode: The interface between the SoC and the PHY (a string that
25 of_get_phy_mode() can understand)
26 - clocks: a pointer to the reference clock for this device.
27
28 -Example:
29 +Optional properties:
30 +
31 +- phy: A phandle to a phy node defining the PHY address (as the reg
32 + property, a single integer). Note: if this property isn't present,
33 + then fixed link is assumed, and the 'fixed-link' property is
34 + mandatory.
35 +- fixed-link: A 5 elements array that describe a fixed link, see
36 + fixed-link.txt for details. Note: if a 'phy' property is present,
37 + this 'fixed-link' property is ignored.
38 +
39 +Examples:
40
41 ethernet@d0070000 {
42 compatible = "marvell,armada-370-neta";
43 @@ -21,3 +29,13 @@ ethernet@d0070000 {
44 phy = <&phy0>;
45 phy-mode = "rgmii-id";
46 };
47 +
48 +ethernet@d0070000 {
49 + compatible = "marvell,armada-370-neta";
50 + reg = <0xd0070000 0x2500>;
51 + interrupts = <8>;
52 + clocks = <&gate_clk 4>;
53 + status = "okay";
54 + fixed-link = <1 1 1000 0 0>;
55 + phy-mode = "rgmii-id";
56 +};
57 --- a/drivers/net/ethernet/marvell/mvneta.c
58 +++ b/drivers/net/ethernet/marvell/mvneta.c
59 @@ -2360,8 +2360,12 @@ static int mvneta_mdio_probe(struct mvne
60 {
61 struct phy_device *phy_dev;
62
63 - phy_dev = of_phy_connect(pp->dev, pp->phy_node, mvneta_adjust_link, 0,
64 - pp->phy_interface);
65 + if (pp->phy_node)
66 + phy_dev = of_phy_connect(pp->dev, pp->phy_node, mvneta_adjust_link, 0,
67 + pp->phy_interface);
68 + else
69 + phy_dev = of_phy_connect_fixed_link(pp->dev, mvneta_adjust_link,
70 + pp->phy_interface);
71 if (!phy_dev) {
72 netdev_err(pp->dev, "could not find the PHY\n");
73 return -ENODEV;
74 @@ -2719,9 +2723,13 @@ static int mvneta_probe(struct platform_
75
76 phy_node = of_parse_phandle(dn, "phy", 0);
77 if (!phy_node) {
78 - dev_err(&pdev->dev, "no associated PHY\n");
79 - err = -ENODEV;
80 - goto err_free_irq;
81 + /* No 'phy' found, see if we have a 'fixed-link'
82 + * property */
83 + err = of_phy_register_fixed_link(dn);
84 + if (err < 0) {
85 + dev_err(&pdev->dev, "no 'phy' or 'fixed-link' properties\n");
86 + goto err_free_irq;
87 + }
88 }
89
90 phy_mode = of_get_phy_mode(dn);