aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2016-02-03 09:33:56 +0000
committerRafał Miłecki <zajec5@gmail.com>2016-02-03 09:33:56 +0000
commit542dafef59cb9751947e8875d695bfed3ca132a2 (patch)
tree90cebc9739b5e9a847c07c4cb493a40212bdb4ac /target
parent1b928961f722dcff21bc894bca8ed2d9afd53e56 (diff)
downloadmaster-187ad058-542dafef59cb9751947e8875d695bfed3ca132a2.tar.gz
master-187ad058-542dafef59cb9751947e8875d695bfed3ca132a2.tar.bz2
master-187ad058-542dafef59cb9751947e8875d695bfed3ca132a2.zip
b53: support setting port link
When dealing with Broadcom hardware we can simply use swconfig's generic helper, we just need to do some validation of requested state. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48623 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/files/drivers/net/phy/b53/b53_common.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
index 41b5ae96c3..676e301559 100644
--- a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
+++ b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c
@@ -794,6 +794,34 @@ static int b53_port_get_link(struct switch_dev *dev, int port,
}
+static int b53_port_set_link(struct switch_dev *sw_dev, int port,
+ struct switch_port_link *link)
+{
+ struct b53_device *dev = sw_to_b53(sw_dev);
+
+ /*
+ * TODO: BCM63XX requires special handling as it can have external phys
+ * and ports might be GE or only FE
+ */
+ if (is63xx(dev))
+ return -ENOTSUPP;
+
+ if (port == sw_dev->cpu_port)
+ return -EINVAL;
+
+ if (!(BIT(port) & dev->enabled_ports))
+ return -EINVAL;
+
+ if (link->speed == SWITCH_PORT_SPEED_1000 &&
+ (is5325(dev) || is5365(dev)))
+ return -EINVAL;
+
+ if (link->speed == SWITCH_PORT_SPEED_1000 && !link->duplex)
+ return -EINVAL;
+
+ return switch_generic_set_link(sw_dev, port, link);
+}
+
static int b53_phy_read16(struct switch_dev *dev, int addr, u8 reg, u16 *value)
{
struct b53_device *priv = sw_to_b53(dev);
@@ -1022,6 +1050,7 @@ static const struct switch_dev_ops b53_switch_ops_25 = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+ .set_port_link = b53_port_set_link,
.phy_read16 = b53_phy_read16,
.phy_write16 = b53_phy_write16,
};
@@ -1047,6 +1076,7 @@ static const struct switch_dev_ops b53_switch_ops_65 = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+ .set_port_link = b53_port_set_link,
.phy_read16 = b53_phy_read16,
.phy_write16 = b53_phy_write16,
};
@@ -1072,6 +1102,7 @@ static const struct switch_dev_ops b53_switch_ops = {
.apply_config = b53_global_apply_config,
.reset_switch = b53_global_reset_switch,
.get_port_link = b53_port_get_link,
+ .set_port_link = b53_port_set_link,
.phy_read16 = b53_phy_read16,
.phy_write16 = b53_phy_write16,
};