From: Tobias Waldekranz <tobias@waldekranz.com>
To: netdev@vger.kernel.org
Subject: [PATCH 2/2] dsa: mv88e6131: support fixed PHYs
Date: Thu, 12 Feb 2015 15:13:17 +0100 [thread overview]
Message-ID: <20150212141317.GB12318@gmail.com> (raw)
Statically setup the PCS Control on the MAC to match the fixed PHY.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
drivers/net/dsa/mv88e6131.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c
index eadb27c..d2b2fcf 100644
--- a/drivers/net/dsa/mv88e6131.c
+++ b/drivers/net/dsa/mv88e6131.c
@@ -337,6 +337,48 @@ mv88e6131_phy_write(struct dsa_switch *ds,
return mv88e6xxx_phy_write_ppu(ds, addr, regnum, val);
}
+static void mv88e6131_adjust_link(struct dsa_switch *ds, int port,
+ struct phy_device *phy)
+{
+ u16 pcs_ctrl;
+
+ /* PPU will configure MACs with physical PHYs */
+ if (!fixed_phy_get_status(phy))
+ return;
+
+ pcs_ctrl = mv88e6xxx_reg_read(ds, REG_PORT(port), 1);
+
+ /* clear all forced settings */
+ pcs_ctrl &= ~0xff;
+ pcs_ctrl |= BIT(2) | BIT(4) | BIT(6);
+
+ switch (phy->speed) {
+ case 10:
+ break;
+ case 100:
+ pcs_ctrl |= BIT(0);
+ break;
+ case 1000:
+ pcs_ctrl |= BIT(1);
+ break;
+
+ default:
+ netdev_err(ds->ports[port], "unsupported speed: %d\n", phy->speed);
+ }
+
+ if (phy->duplex)
+ pcs_ctrl |= BIT(3);
+
+ if (phy->link)
+ pcs_ctrl |= BIT(5);
+
+ if (phy->pause)
+ pcs_ctrl |= BIT(7);
+
+ mv88e6xxx_reg_write(ds, REG_PORT(port), 1, pcs_ctrl);
+ return;
+}
+
static struct mv88e6xxx_hw_stat mv88e6131_hw_stats[] = {
{ "in_good_octets", 8, 0x00, },
{ "in_bad_octets", 4, 0x02, },
@@ -398,6 +440,7 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
.set_addr = mv88e6xxx_set_addr_direct,
.phy_read = mv88e6131_phy_read,
.phy_write = mv88e6131_phy_write,
+ .adjust_link = mv88e6131_adjust_link,
.poll_link = mv88e6xxx_poll_link,
.get_strings = mv88e6131_get_strings,
.get_ethtool_stats = mv88e6131_get_ethtool_stats,
--
1.8.4.357.g8d83871.dirty
next reply other threads:[~2015-02-12 14:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-12 14:13 Tobias Waldekranz [this message]
2015-02-12 16:13 ` [PATCH 2/2] dsa: mv88e6131: support fixed PHYs Florian Fainelli
2015-02-21 10:30 ` Tobias Waldekranz
2015-02-21 18:56 ` Florian Fainelli
2015-02-23 11:13 ` Tobias Waldekranz
2015-02-23 17:49 ` Florian Fainelli
2015-02-19 20:19 ` David Miller
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=20150212141317.GB12318@gmail.com \
--to=tobias@waldekranz.com \
--cc=netdev@vger.kernel.org \
/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).