ipq806x: convert to using qca8k
[openwrt/staging/blogic.git] / target / linux / ipq806x / patches-4.9 / 906-net-dsa-qca8k-allow-swapping-of-mac0-and-mac6.patch
1 From fd18a10a9f172dcc78629669ce60304924c5a2fb Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Thu, 15 Dec 2016 04:40:55 +0100
4 Subject: [PATCH 17/22] net: dsa: qca8k: allow swapping of mac0 and mac6
5
6 The switch allows us to swap the internal wirering of the two cpu ports.
7 For the HW offloading to work the ethernet MAC conencting to the LAN
8 ports must be wired to cpu port 0. There is HW in the wild that does not
9 fulfill this requirement. On these boards we need to swap the cpu ports.
10
11 Signed-off-by: John Crispin <john@phrozen.org>
12 ---
13 drivers/net/dsa/qca8k.c | 15 +++++++++++++++
14 1 file changed, 15 insertions(+)
15
16 Index: linux-4.9.34/drivers/net/dsa/qca8k.c
17 ===================================================================
18 --- linux-4.9.34.orig/drivers/net/dsa/qca8k.c
19 +++ linux-4.9.34/drivers/net/dsa/qca8k.c
20 @@ -518,6 +518,18 @@ qca8k_port_set_status(struct qca8k_priv
21 qca8k_reg_clear(priv, QCA8K_REG_PORT_STATUS(port), mask);
22 }
23
24 +static void
25 +qca8k_exchange_mac06(struct qca8k_priv *priv, struct device_node *np)
26 +{
27 + u32 val = qca8k_read(priv, QCA8K_REG_PORT0_PAD_CTRL);
28 +
29 + if (of_property_read_bool(np, "qca,exchange_mac06"))
30 + val |= QCA8K_PORT0_PAD_CTRL_MAC06_EXCHG;
31 + else
32 + val &= ~QCA8K_PORT0_PAD_CTRL_MAC06_EXCHG;
33 + qca8k_write(priv, QCA8K_REG_PORT0_PAD_CTRL, val);
34 +}
35 +
36 static int
37 qca8k_setup(struct dsa_switch *ds)
38 {
39 @@ -538,6 +550,9 @@ qca8k_setup(struct dsa_switch *ds)
40 if (IS_ERR(priv->regmap))
41 pr_warn("regmap initialization failed");
42
43 + /* Exchange MAC0 and MAC6 */
44 + qca8k_exchange_mac06(priv, priv->ds->dev->of_node);
45 +
46 /* Initialize CPU port pad mode (xMII type, delays...) */
47 phy_mode = of_get_phy_mode(ds->ports[ds->dst->cpu_port].dn);
48 if (phy_mode < 0) {