[OpenWrt-Devel] [PATCH 2/2] b53: support setting port link state
Jonas Gorski
jogo at openwrt.org
Mon Jan 18 08:21:03 EST 2016
Hi,
On 6 January 2016 at 20:02, Rafał Miłecki <zajec5 at gmail.com> wrote:
> Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
> ---
> .../generic/files/drivers/net/phy/b53/b53_common.c | 40 ++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> 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 859d8d1..42a1679 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
> @@ -25,6 +25,7 @@
> #include <linux/module.h>
> #include <linux/switch.h>
> #include <linux/platform_data/b53.h>
> +#include <uapi/linux/mii.h>
>
> #include "b53_regs.h"
> #include "b53_priv.h"
> @@ -794,6 +795,42 @@ static int b53_port_get_link(struct switch_dev *dev, int port,
>
> }
>
> +static int b53_port_set_link(struct switch_dev *dev, int port,
> + struct switch_port_link *link)
> +{
> + struct b53_device *priv = sw_to_b53(dev);
> +
> + if (!priv->ops->phy_write16)
> + return -ENOTSUPP;
Oh, you do the check here, that was unexpected.
You should also disallow reconfiguration of non-(e)phy ports like the cpu port.
> +
> + if (link->aneg) {
> + b53_phy_write16(priv, port, MII_BMCR, 0x0000);
> + b53_phy_write16(priv, port, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
> + } else {
> + u16 bmcr = 0;
> +
> + if (link->duplex)
> + bmcr |= BMCR_FULLDPLX;
> +
> + switch (link->speed) {
> + case SWITCH_PORT_SPEED_10:
> + break;
> + case SWITCH_PORT_SPEED_100:
> + bmcr |= BMCR_SPEED100;
> + break;
> + case SWITCH_PORT_SPEED_1000:
> + bmcr |= BMCR_SPEED1000;
b53 supports switches with fast ethernet only ports, so you need to
make sure that you don't try to set gige speed on them.
> + break;
> + default:
> + return -ENOTSUPP;
> + }
> +
> + b53_phy_write16(priv, port, MII_BMCR, bmcr);
> + }
> +
> + return 0;
This function does nothing broadcom/b53 specific. I would think that
exposing the phys over the mdio bus is rather common for switches, so
I wonder if it wouldn't make more sense to have generic write/read mii
page function pointers for swconfig and move this function to the
swconfig common code.
Jonas
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list