From: Mathieu Olivari <mathieu@codeaurora.org>
To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
davem@davemloft.net, mathieu@codeaurora.org, andrew@lunn.ch,
f.fainelli@gmail.com, linux@roeck-us.net,
gang.chen.5i5j@gmail.com, jiri@resnulli.us, leitec@staticky.com,
fabf@skynet.be, alexander.h.duyck@intel.com,
pavel.nakonechny@skitlab.ru, joe@perches.com, sfeldma@gmail.com,
nbd@openwrt.org, juhosg@openwrt.org
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: [PATCH 6/7] net: dsa: ar8xxx: add support for second xMII interfaces through DT
Date: Thu, 28 May 2015 18:42:21 -0700 [thread overview]
Message-ID: <1432863742-18427-7-git-send-email-mathieu@codeaurora.org> (raw)
In-Reply-To: <1432863742-18427-1-git-send-email-mathieu@codeaurora.org>
This patch is adding support for port6 specific options to device tree.
They can be used to setup the second xMII interface, and connect it to
one of the switch port.
Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org>
---
drivers/net/dsa/ar8xxx.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/net/dsa/ar8xxx.c b/drivers/net/dsa/ar8xxx.c
index 4044614..7559249 100644
--- a/drivers/net/dsa/ar8xxx.c
+++ b/drivers/net/dsa/ar8xxx.c
@@ -19,6 +19,7 @@
#include <net/dsa.h>
#include <linux/phy.h>
#include <linux/of_net.h>
+#include <linux/of_platform.h>
#include "ar8xxx.h"
@@ -260,6 +261,9 @@ static int ar8xxx_set_pad_ctrl(struct dsa_switch *ds, int port, int mode)
ar8xxx_write(ds, AR8327_REG_PORT5_PAD_CTRL,
AR8327_PORT_PAD_RGMII_RX_DELAY_EN);
break;
+ case PHY_INTERFACE_MODE_SGMII:
+ ar8xxx_write(ds, reg, AR8327_PORT_PAD_SGMII_EN);
+ break;
default:
pr_err("xMII mode %d not supported\n", mode);
return -EINVAL;
@@ -268,6 +272,48 @@ static int ar8xxx_set_pad_ctrl(struct dsa_switch *ds, int port, int mode)
return 0;
}
+static int ar8xxx_of_setup(struct dsa_switch *ds)
+{
+ struct device_node *dn = ds->pd->of_node;
+ const char *s_phymode;
+ int ret, mode;
+ u32 phy_id, ctrl;
+
+ /* If port6-phy-mode property exists, configure it accordingly */
+ if (!of_property_read_string(dn, "qca,port6-phy-mode", &s_phymode)) {
+ for (mode = 0; mode < PHY_INTERFACE_MODE_MAX; mode++)
+ if (!strcasecmp(s_phymode, phy_modes(mode)))
+ break;
+
+ if (mode == PHY_INTERFACE_MODE_MAX)
+ pr_err("Unknown phy-mode: \"%s\"\n", s_phymode);
+
+ ret = ar8xxx_set_pad_ctrl(ds, 6, mode);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* If a phy ID is specified for PORT6 mac, connect them together */
+ if (!of_property_read_u32(dn, "qca,port6-phy-id", &phy_id)) {
+ ar8xxx_rmw(ds, AR8327_PORT_LOOKUP_CTRL(6),
+ AR8327_PORT_LOOKUP_MEMBER, BIT(phy_to_port(phy_id)));
+ ar8xxx_rmw(ds, AR8327_PORT_LOOKUP_CTRL(phy_to_port(phy_id)),
+ AR8327_PORT_LOOKUP_MEMBER, BIT(6));
+
+ /* We want the switch to be pass-through and act like a PHY on
+ * these ports. So BC/MC/UC & IGMP frames need to be accepted
+ */
+ ctrl = BIT(phy_to_port(phy_id)) | BIT(6);
+ ar8xxx_reg_set(ds, AR8327_REG_GLOBAL_FW_CTRL1,
+ ctrl << AR8327_GLOBAL_FW_CTRL1_IGMP_DP_S |
+ ctrl << AR8327_GLOBAL_FW_CTRL1_BC_DP_S |
+ ctrl << AR8327_GLOBAL_FW_CTRL1_MC_DP_S |
+ ctrl << AR8327_GLOBAL_FW_CTRL1_UC_DP_S);
+ }
+
+ return 0;
+}
+
static int ar8xxx_setup(struct dsa_switch *ds)
{
struct ar8xxx_priv *priv = ds_to_priv(ds);
@@ -341,6 +387,10 @@ static int ar8xxx_setup(struct dsa_switch *ds)
}
}
+ ret = ar8xxx_of_setup(ds);
+ if (ret < 0)
+ return ret;
+
return 0;
}
--
2.1.4
next prev parent reply other threads:[~2015-05-29 1:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 1:42 [PATCH 0/7] net: dsa: add QCA AR8xxx switch family support Mathieu Olivari
2015-05-29 1:42 ` [PATCH 3/7] net: dsa: ar8xxx: add regmap support Mathieu Olivari
2015-05-29 1:58 ` Florian Fainelli
[not found] ` <5567C7B6.5060905-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-29 2:23 ` Andrew Lunn
[not found] ` <20150529022329.GH11260-g2DYL2Zd6BY@public.gmane.org>
2015-05-29 2:36 ` Florian Fainelli
[not found] ` <5567D0BA.5020409-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-29 2:44 ` Andrew Lunn
[not found] ` <20150529024425.GI11260-g2DYL2Zd6BY@public.gmane.org>
2015-05-29 17:36 ` Mathieu Olivari
2015-05-29 17:59 ` Andrew Lunn
2015-05-30 22:38 ` Sergey Ryazanov
2015-05-29 1:42 ` [PATCH 4/7] net: dsa: add QCA tag support Mathieu Olivari
[not found] ` <1432863742-18427-1-git-send-email-mathieu-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-05-29 1:42 ` [PATCH 1/7] net: dsa: add new driver for ar8xxx family Mathieu Olivari
[not found] ` <1432863742-18427-2-git-send-email-mathieu-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-05-29 2:08 ` Andrew Lunn
2015-06-01 8:14 ` Paul Bolle
2015-05-29 1:42 ` [PATCH 2/7] net: dsa: ar8xxx: add ethtool hw statistics support Mathieu Olivari
2015-05-29 1:42 ` [PATCH 5/7] net: dsa: ar8xxx: enable QCA header support on AR8xxx Mathieu Olivari
2015-05-29 1:42 ` Mathieu Olivari [this message]
2015-05-29 1:42 ` [PATCH 7/7] Documentation: devicetree: add ar8xxx binding Mathieu Olivari
[not found] ` <1432863742-18427-8-git-send-email-mathieu-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-05-29 2:04 ` Florian Fainelli
2015-05-29 2:00 ` [PATCH 0/7] net: dsa: add QCA AR8xxx switch family support Andrew Lunn
2015-05-29 18:49 ` [PATCH 0/7] net: dsa: add QCA AR8xxx switch family support\ Mathieu Olivari
[not found] ` <20150529184951.GA2458-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-05-29 18:59 ` Andrew Lunn
2015-05-29 19:58 ` Florian Fainelli
[not found] ` <5568C4D4.7010701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-29 19:59 ` Mathieu Olivari
[not found] ` <20150529195955.GA2884-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-05-29 20:01 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432863742-18427-7-git-send-email-mathieu@codeaurora.org \
--to=mathieu@codeaurora.org \
--cc=alexander.h.duyck@intel.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=fabf@skynet.be \
--cc=galak@codeaurora.org \
--cc=gang.chen.5i5j@gmail.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jiri@resnulli.us \
--cc=joe@perches.com \
--cc=juhosg@openwrt.org \
--cc=leitec@staticky.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=nbd@openwrt.org \
--cc=netdev@vger.kernel.org \
--cc=pavel.nakonechny@skitlab.ru \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sfeldma@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).